This commit is contained in:
Jabberwocky238
2026-07-17 05:32:14 -04:00
parent a289f1b911
commit 67c07b3bcf
34 changed files with 791 additions and 1 deletions
+10 -1
View File
@@ -132,7 +132,16 @@ func (s *LocalState) CreateRepo(ns, name string) error {
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
return fmt.Errorf("create repo: mkdir ns: %w", err)
}
if out, err := exec.Command("git", "init", "--bare", path).CombinedOutput(); err != nil {
// Use the hook template (materialized by the daemon at startup) so every new
// repo gets forwarding hooks for all git hook types. Fall back to a plain
// init if the template is absent (e.g. a state test without the daemon);
// such a repo simply has no hooks and pushes still work.
initArgs := []string{"init", "--bare"}
if fi, err := os.Stat(s.cfg.TemplateDir()); err == nil && fi.IsDir() {
initArgs = append(initArgs, "--template="+s.cfg.TemplateDir())
}
initArgs = append(initArgs, path)
if out, err := exec.Command("git", initArgs...).CombinedOutput(); err != nil {
return fmt.Errorf("create repo: git init: %w: %s", err, strings.TrimSpace(string(out)))
}