]> source.dussan.org Git - gitea.git/commitdiff
Fix ambiguous argument error on tags (#15432)
authorzeripath <art27@cantab.net>
Wed, 14 Apr 2021 14:22:37 +0000 (15:22 +0100)
committerGitHub <noreply@github.com>
Wed, 14 Apr 2021 14:22:37 +0000 (16:22 +0200)
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 <art27@cantab.net>
modules/git/repo_commit.go

index ea0aeeb35d3701c09d1f35c88ebacf3e478028dd..5e2db34fd18e30f47ddd25543b89f4bfc8299c68 100644 (file)
@@ -21,14 +21,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)
 }
 
 // ConvertToSHA1 returns a Hash object from a potential ID string