aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/vcs/git_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/vcs/git_test.go')
-rw-r--r--pkg/vcs/git_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/vcs/git_test.go b/pkg/vcs/git_test.go
index 5e9d30fa7..73670dd4a 100644
--- a/pkg/vcs/git_test.go
+++ b/pkg/vcs/git_test.go
@@ -426,3 +426,22 @@ func TestGitRemoteTags(t *testing.T) {
sort.Strings(tags)
assert.Equal(t, []string{"v1.0", "v2.0"}, tags)
}
+
+func TestGitFetchShortHash(t *testing.T) {
+ remoteRepoDir := t.TempDir()
+ remote := MakeTestRepo(t, remoteRepoDir)
+ remote.Git("commit", "--no-edit", "--allow-empty", "-m", "base commit")
+ remote.Git("checkout", "-b", "base_branch")
+ remote.Git("tag", "base_tag")
+ remote.Git("checkout", "-b", "temp_branch")
+ remote.Git("commit", "--no-edit", "--allow-empty", "-m", "detached commit")
+ refCommit, _ := remote.repo.HeadCommit()
+
+ // Create a local repo.
+ localRepoDir := t.TempDir()
+ local := newGit(localRepoDir, nil, nil)
+
+ // Fetch the commit from the custom ref.
+ _, err := local.CheckoutCommit(remoteRepoDir, refCommit.Hash[:12])
+ assert.NoError(t, err)
+}