Merge pull request #545 from bigkevmcd/fix-failure-default-branch

This commit is contained in:
Hidde Beydals 2022-01-17 16:02:06 +01:00 committed by GitHub
commit be575864e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -37,6 +37,18 @@ func TestCheckoutBranch_Checkout(t *testing.T) {
defer repo.Free()
defer os.RemoveAll(filepath.Join(repo.Path(), ".."))
cfg, err := git2go.OpenDefault()
if err != nil {
t.Fatal(err)
}
// 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 = v
}
firstCommit, err := commitFile(repo, "branch", "init", time.Now())
if err != nil {
t.Fatal(err)
@ -59,7 +71,7 @@ func TestCheckoutBranch_Checkout(t *testing.T) {
}{
{
name: "Default branch",
branch: "master",
branch: defaultBranch,
expectedCommit: secondCommit.String(),
},
{