diff options
Diffstat (limited to 'internal/api/webhook_test.go')
| -rw-r--r-- | internal/api/webhook_test.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/api/webhook_test.go b/internal/api/webhook_test.go index 05fe82c..f0ede7c 100644 --- a/internal/api/webhook_test.go +++ b/internal/api/webhook_test.go @@ -422,11 +422,21 @@ func TestGitHubWebhook_PushEvent_SyncsLocalBareRepo(t *testing.T) { // Create a "github" source bare repo with a commit. githubBare := filepath.Join(dir, "github.git") localBare := filepath.Join(dir, "local.git") - for _, bare := range []string{githubBare, localBare} { - if out, err := exec.Command("git", "init", "--bare", bare).CombinedOutput(); err != nil { - t.Fatalf("git init bare %s: %v\n%s", bare, err, out) + initBare := func(path string) { + t.Helper() + out, err := exec.Command("git", "init", "--bare", "--initial-branch=main", path).CombinedOutput() + if err != nil { + // Fallback for older git: init then update HEAD to main. + if out2, err2 := exec.Command("git", "init", "--bare", path).CombinedOutput(); err2 != nil { + t.Fatalf("git init bare %s: %v\n%s", path, err2, out2) + } + if out2, err2 := exec.Command("git", "-C", path, "symbolic-ref", "HEAD", "refs/heads/main").CombinedOutput(); err2 != nil { + t.Fatalf("set HEAD to main %s: %v\n%s\n%s", path, err, out, out2) + } } } + initBare(githubBare) + initBare(localBare) // Seed githubBare with a commit via a temp clone. clone := filepath.Join(dir, "clone") run := func(args ...string) { |
