Skip to content

Commit 662409b

Browse files
committed
Suppress git hint about default branch name in test
This silences the unnecessary git hint visible when running `go test`: === RUN TestSnapshotVersion hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch <name> hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m <name> hint: hint: Disable this message with "git config set advice.defaultBranchName false"
1 parent f0993ac commit 662409b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

version_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ func TestSnapshotVersion(t *testing.T) {
3232
t.Fatalf("Could not write temp file %q: %v", tempfile, err)
3333
}
3434

35-
gitCmdOrFatal(t, tempdir, "init")
35+
// Suppress git hint about default branch name by setting init.defaultBranch
36+
gitCmdOrFatal(t, tempdir, "init", "--initial-branch=master")
3637
gitCmdOrFatal(t, tempdir, "config", "user.email", "unittest@example.com")
3738
gitCmdOrFatal(t, tempdir, "config", "user.name", "Unit Test")
3839
gitCmdOrFatal(t, tempdir, "add", "test")

0 commit comments

Comments
 (0)