@@ -7,13 +7,15 @@ import (
7
7
"fmt"
8
8
"net/http"
9
9
"net/http/httptest"
10
+ "os"
10
11
"path/filepath"
11
12
"testing"
12
13
13
14
"github.com/fluxcd/gitkit"
14
15
"github.com/go-git/go-billy/v5/memfs"
15
16
"github.com/go-git/go-git/v5"
16
17
"github.com/go-git/go-git/v5/config"
18
+ "github.com/go-git/go-git/v5/plumbing"
17
19
"github.com/go-git/go-git/v5/plumbing/object"
18
20
"github.com/go-git/go-git/v5/storage/memory"
19
21
"github.com/stretchr/testify/require"
@@ -47,7 +49,10 @@ func TestRepository(t *testing.T) {
47
49
48
50
storer := memory .NewStorage ()
49
51
fs := memfs .New ()
50
- initRepo , err := git .Init (storer , fs )
52
+ options := git.InitOptions {
53
+ DefaultBranch : plumbing .Main ,
54
+ }
55
+ initRepo , err := git .InitWithOptions (storer , fs , options )
51
56
require .NoError (t , err )
52
57
w , err := initRepo .Worktree ()
53
58
require .NoError (t , err )
@@ -76,6 +81,12 @@ func TestRepository(t *testing.T) {
76
81
})
77
82
require .NoError (t , err )
78
83
84
+ // TODO: Is there a configuration that defines contents of HEAD that isn't read from ~/.gitconfig
85
+ // Force-write refs/heads/main ref to HEAD to disk - Matching the above reference and decoupling from host gitconfig
86
+ headFile := filepath .Join (cfg .Dir , "test.git" , "HEAD" )
87
+ err = os .WriteFile (headFile , []byte ("ref: refs/heads/main\n " ), 0644 )
88
+ require .NoError (t , err , "Failed to write HEAD to disk" )
89
+
79
90
repo , err := Clone (ctx , rootPath , repoAddress , false )
80
91
require .NoError (t , err )
81
92
require .Equal (t , filepath .Join (rootPath , expectedPath ), repo .Path ())
0 commit comments