1
This commit is contained in:
+10
-1
@@ -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)))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user