From c840dac2ebfe3e2e20e461e6db7d2aac65caa55d Mon Sep 17 00:00:00 2001 From: Guy Owen Date: Tue, 24 Oct 2023 10:46:31 +1100 Subject: [PATCH] [#2056] Fixed failing tests. --- pkg/common/git/git.go | 5 ++++- pkg/common/git/git_test.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/common/git/git.go b/pkg/common/git/git.go index e155c677b25..b6a009c1c0f 100644 --- a/pkg/common/git/git.go +++ b/pkg/common/git/git.go @@ -100,7 +100,10 @@ func FindGitRef(ctx context.Context, file string) (string, error) { return "", err } - headRef, _ := repo.Head() + headRef, err := repo.Head() + if err != nil { + return "", err + } logger.Debugf("HEAD points to revision '%s'", headRef.Hash().String()) // The assumption is made that if the revision has a tag associated with it the ref and ref_name should reference it. diff --git a/pkg/common/git/git_test.go b/pkg/common/git/git_test.go index f340e9f687a..a688dd90d51 100644 --- a/pkg/common/git/git_test.go +++ b/pkg/common/git/git_test.go @@ -164,6 +164,7 @@ func TestGitFindRef(t *testing.T) { }, "current_head_is_master_and_pointer_exists_to_another_branch": { Prepare: func(t *testing.T, dir string) { + require.NoError(t, gitCmd("-C", dir, "commit", "--allow-empty", "-m", "msg")) require.NoError(t, gitCmd("-C", dir, "checkout", "-b", "mybranch")) require.NoError(t, gitCmd("-C", dir, "checkout", "master")) },