Skip to content

Commit 2f19caf

Browse files
committed
util/gitutil: fix TestGitFullCommitErr/TestGitShortCommitErr
git rev-parse HEAD doesn't need any `--`, however, when it is called on an empty repo git returns an error: ``` fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' ``` So, it is both IsUnknownRevision and IsAmbiguousArgument. Lets simply fix the test by flipping the check: I don't see any dependency on this behavior in non-test code.
1 parent ba6eae3 commit 2f19caf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

util/gitutil/gitutil_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestGitFullCommitErr(t *testing.T) {
6262
_, err = c.FullCommit()
6363
require.Error(t, err)
6464
require.True(t, gitutil.IsUnknownRevision(err))
65-
require.False(t, gittestutil.IsAmbiguousArgument(err))
65+
require.True(t, gittestutil.IsAmbiguousArgument(err))
6666
}
6767

6868
func TestGitShortCommitErr(t *testing.T) {
@@ -75,7 +75,7 @@ func TestGitShortCommitErr(t *testing.T) {
7575
_, err = c.ShortCommit()
7676
require.Error(t, err)
7777
require.True(t, gitutil.IsUnknownRevision(err))
78-
require.False(t, gittestutil.IsAmbiguousArgument(err))
78+
require.True(t, gittestutil.IsAmbiguousArgument(err))
7979
}
8080

8181
func TestGitTagsPointsAt(t *testing.T) {

0 commit comments

Comments
 (0)