diff options
Diffstat (limited to 'pkg/config/lib/git/git.go')
| -rw-r--r-- | pkg/config/lib/git/git.go | 34 | 
1 files changed, 34 insertions, 0 deletions
diff --git a/pkg/config/lib/git/git.go b/pkg/config/lib/git/git.go new file mode 100644 index 0000000..f1e0607 --- /dev/null +++ b/pkg/config/lib/git/git.go @@ -0,0 +1,34 @@ +// Package git provides Starlark macros to declare modules hosted on Git +// repositories. +package git + +import ( +	_ "embed" +	"go.nc0.fr/svgu/pkg/config" +	"go.starlark.net/starlark" +	"go.starlark.net/starlarkstruct" +	"sync" +) + +var ( +	once = sync.Once{} +	git  = starlark.StringDict{} +	//go:embed git.star +	gitFile string +	gitErr  error +) + +// LoadGitModule loads the git module. +func LoadGitModule(t *starlark.Thread) (starlark.StringDict, error) { +	once.Do(func() { +		env := starlark.StringDict{ +			"module": starlark.NewBuiltin("module", +				config.InternModule), +			"make_module": starlark.NewBuiltin("mod", +				starlarkstruct.MakeModule), +		} +		git, gitErr = starlark.ExecFile(t, "git.star", gitFile, env) +	}) + +	return git, gitErr +}  | 
