Skip to content

Commit

Permalink
Do not use lower tag names to find releases/tags (go-gitea#29261)
Browse files Browse the repository at this point in the history
Fix go-gitea#26090, see
go-gitea#26090 (comment)

Since `TagName` stores the original tag name and `LowerTagName` stores
the lower tag name, it doesn't make sense to use lowercase tags as
`TagNames` in `FindReleasesOptions`.

https://github.com/go-gitea/gitea/blob/5e72526da4e915791f03af056890e16821bde052/services/repository/push.go#L396-L397

While the only other usage looks correct:

https://github.com/go-gitea/gitea/blob/5e72526da4e915791f03af056890e16821bde052/routers/web/repo/repo.go#L416
(cherry picked from commit 0ea8de2)
  • Loading branch information
wolfogre authored and earl-warren committed Feb 19, 2024
1 parent b3f2447 commit e96e1be
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions services/repository/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,9 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
return nil
}

lowerTags := make([]string, 0, len(tags))
for _, tag := range tags {
lowerTags = append(lowerTags, strings.ToLower(tag))
}

releases, err := db.Find[repo_model.Release](ctx, repo_model.FindReleasesOptions{
RepoID: repo.ID,
TagNames: lowerTags,
TagNames: tags,
})
if err != nil {
return fmt.Errorf("db.Find[repo_model.Release]: %w", err)
Expand All @@ -338,6 +333,11 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
relMap[rel.LowerTagName] = rel
}

lowerTags := make([]string, 0, len(tags))
for _, tag := range tags {
lowerTags = append(lowerTags, strings.ToLower(tag))
}

newReleases := make([]*repo_model.Release, 0, len(lowerTags)-len(relMap))

emailToUser := make(map[string]*user_model.User)
Expand Down

0 comments on commit e96e1be

Please sign in to comment.