Skip to content

Commit 05f266c

Browse files
authored
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 <[email protected]>
1 parent bec6051 commit 05f266c

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

modules/git/repo_commit.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,7 @@ func (repo *Repository) GetBranchCommitID(name string) (string, error) {
4747

4848
// GetTagCommitID returns last commit ID string of given tag.
4949
func (repo *Repository) GetTagCommitID(name string) (string, error) {
50-
stdout, err := NewCommand("rev-list", "-n", "1", TagPrefix+name).RunInDir(repo.Path)
51-
if err != nil {
52-
if strings.Contains(err.Error(), "unknown revision or path") {
53-
return "", ErrNotExist{name, ""}
54-
}
55-
return "", err
56-
}
57-
return strings.TrimSpace(stdout), nil
50+
return repo.GetRefCommitID(TagPrefix + name)
5851
}
5952

6053
func convertPGPSignatureForTag(t *object.Tag) *CommitGPGSignature {

0 commit comments

Comments
 (0)