blob: f1e0607a75ba047a5067b02a2c0a525d0ad8405f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
}
|