diff --git a/pkg/git/libgit2/checkout_test.go b/pkg/git/libgit2/checkout_test.go index f648eae6..3f9e451d 100644 --- a/pkg/git/libgit2/checkout_test.go +++ b/pkg/git/libgit2/checkout_test.go @@ -51,8 +51,8 @@ func TestCheckoutBranch_Checkout(t *testing.T) { // ignores the error here because it can be defaulted // https://github.blog/2020-07-27-highlights-from-git-2-28/#introducing-init-defaultbranch - defaultBranch := "main" - if v, err := cfg.LookupString("init.defaultBranch"); err != nil { + defaultBranch := "master" + if v, err := cfg.LookupString("init.defaultBranch"); err != nil && v != "" { defaultBranch = v } @@ -61,10 +61,12 @@ func TestCheckoutBranch_Checkout(t *testing.T) { t.Fatal(err) } + // Branch off on first commit if err = createBranch(repo, "test", nil); err != nil { t.Fatal(err) } + // Create second commit on default branch secondCommit, err := commitFile(repo, "branch", "second", time.Now()) if err != nil { t.Fatal(err)