Skip to content

Commit 5f0ed94

Browse files
committed
Make test work with different default branch config
On a system configured with a different default branch name, doGitInitTestRepository will create a repository with a branch named differently, and so further tests would break: --- FAIL: TestGit/HTTP/PushCreate/SuccessfullyPushAndCreateTestRepository (0.02s) git_helper_for_declarative_test.go:167: Error Trace: git_helper_for_declarative_test.go:167 Error: Received unexpected error: exit status 1 - error: src refspec master does not match any error: failed to push some refs to 'http://127.0.0.1:3003/user2/repo-tmp-push-create-http.git' Test: TestGit/HTTP/PushCreate/SuccessfullyPushAndCreateTestRepository git_test.go:587: Error Trace: git_test.go:587 Error: Received unexpected error: repository does not exist [id: 0, uid: 0, owner_name: user2, name: repo-tmp-push-create-http] Test: TestGit/HTTP/PushCreate
1 parent 4bbbf35 commit 5f0ed94

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

integrations/git_helper_for_declarative_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ func doGitInitTestRepository(dstPath string) func(*testing.T) {
139139
return func(t *testing.T) {
140140
// Init repository in dstPath
141141
assert.NoError(t, git.InitRepository(dstPath, false))
142+
repo, err := git.OpenRepository(dstPath)
143+
assert.NoError(t, err)
144+
assert.NoError(t, repo.SetDefaultBranch("master"))
145+
assert.NoError(t, repo.Close())
142146
assert.NoError(t, os.WriteFile(filepath.Join(dstPath, "README.md"), []byte(fmt.Sprintf("# Testing Repository\n\nOriginally created in: %s", dstPath)), 0644))
143147
assert.NoError(t, git.AddChanges(dstPath, true))
144148
signature := git.Signature{

0 commit comments

Comments
 (0)