From 05f266c3315aec95f4cf18a9938decd707603e53 Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 14 Apr 2021 19:52:55 +0100 Subject: [PATCH] Fix ambiguous argument error on tags (#15432) (#15475) Backport #15432 There is a weird gotcha with GetTagCommitID that because it uses git rev-list can cause an ambiguous argument error. This PR simply makes tags use the same code as branches. Signed-off-by: Andrew Thornton --- modules/git/repo_commit.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index 70fe6fbcdb5..ebecfd10389 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -47,14 +47,7 @@ func (repo *Repository) GetBranchCommitID(name string) (string, error) { // GetTagCommitID returns last commit ID string of given tag. func (repo *Repository) GetTagCommitID(name string) (string, error) { - stdout, err := NewCommand("rev-list", "-n", "1", TagPrefix+name).RunInDir(repo.Path) - if err != nil { - if strings.Contains(err.Error(), "unknown revision or path") { - return "", ErrNotExist{name, ""} - } - return "", err - } - return strings.TrimSpace(stdout), nil + return repo.GetRefCommitID(TagPrefix + name) } func convertPGPSignatureForTag(t *object.Tag) *CommitGPGSignature {