Skip to content

Commit 5f05477

Browse files
committed
Fix ambiguous argument error on tags (go-gitea#15432)
Backport go-gitea#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 fa3fe1e commit 5f05477

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
@@ -21,14 +21,7 @@ func (repo *Repository) GetBranchCommitID(name string) (string, error) {
2121

2222
// GetTagCommitID returns last commit ID string of given tag.
2323
func (repo *Repository) GetTagCommitID(name string) (string, error) {
24-
stdout, err := NewCommand("rev-list", "-n", "1", TagPrefix+name).RunInDir(repo.Path)
25-
if err != nil {
26-
if strings.Contains(err.Error(), "unknown revision or path") {
27-
return "", ErrNotExist{name, ""}
28-
}
29-
return "", err
30-
}
31-
return strings.TrimSpace(stdout), nil
24+
return repo.GetRefCommitID(TagPrefix + name)
3225
}
3326

3427
// ConvertToSHA1 returns a Hash object from a potential ID string

0 commit comments

Comments
 (0)