Skip to content

Commit aa894f2

Browse files
mrsdizzieYohann Delafollye
authored andcommitted
Fix 500 error on repos with no tags (go-gitea#11870)
go-gitea#11846 Introduced feature to show exact tag on commit view. However if a repo has no tags at all git prints out a separate and unhandled error " No names found, cannot describe anything." Adding --always to the command makes it always use the error in the style of "fatal: no tag exactly matches" even if there are no tags at all. Fixes go-gitea#11869 Fixes go-gitea#11868
1 parent eeb0bfc commit aa894f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/git/commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func (c *Commit) GetBranchName() (string, error) {
484484

485485
// GetTagName gets the current tag name for given commit
486486
func (c *Commit) GetTagName() (string, error) {
487-
data, err := NewCommand("describe", "--exact-match", "--tags", c.ID.String()).RunInDir(c.repo.Path)
487+
data, err := NewCommand("describe", "--exact-match", "--tags", "--always", c.ID.String()).RunInDir(c.repo.Path)
488488
if err != nil {
489489
// handle special case where there is no tag for this commit
490490
if strings.Contains(err.Error(), "no tag exactly matches") {

0 commit comments

Comments
 (0)