diff options
Diffstat (limited to '')
-rw-r--r-- | config.go | 7 | ||||
-rw-r--r-- | forge.scfg | 5 | ||||
-rw-r--r-- | git_init.go | 28 |
3 files changed, 35 insertions, 5 deletions
@@ -21,9 +21,10 @@ var config struct { CookieExpiry int `scfg:"cookie_expiry"` Root string `scfg:"root"` } `scfg:"http"` - Git struct { - HooksSocket string `scfg:"hooks_socket"` - } `scfg:"git"` + Hooks struct { + Socket string `scfg:"socket"` + Execs string `scfg:"execs"` + } `scfg:"hooks"` SSH struct { Net string `scfg:"net"` Addr string `scfg:"addr"` @@ -21,6 +21,7 @@ db { conn postgresql:///lindenii-forge?host=/var/run/postgresql } -git { - hooks_socket /var/run/lindenii/forge/hooks.sock +hooks { + socket /var/run/lindenii/forge/hooks.sock + execs /usr/libexec/lindenii/forge/hooks } diff --git a/git_init.go b/git_init.go new file mode 100644 index 0000000..466628f --- /dev/null +++ b/git_init.go @@ -0,0 +1,28 @@ +package main + + +import ( + "github.com/go-git/go-git/v5" + git_format_config "github.com/go-git/go-git/v5/plumbing/format/config" +) + +func git_bare_init_with_default_hooks(repo_path string) (err error) { + repo, err := git.PlainInit(repo_path, true) + if err != nil { + return err + } + + git_config, err := repo.Config() + if err != nil { + return err + } + + git_config.Raw.SetOption("core", git_format_config.NoSubsection, "hooksPath", config.Hooks.Execs) + + err = repo.SetConfig(git_config) + if err != nil { + return err + } + + return nil +} |