Skip to content

Commit

Permalink
Fix 500 error on repos with no tags (go-gitea#11870)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mrsdizzie authored and Yohann Delafollye committed Jul 31, 2020
1 parent eeb0bfc commit aa894f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/git/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (c *Commit) GetBranchName() (string, error) {

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

0 comments on commit aa894f2

Please sign in to comment.