summaryrefslogtreecommitdiffstats
path: root/modules/repository
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-10-12 07:18:26 +0200
committerGitHub <noreply@github.com>2022-10-12 13:18:26 +0800
commit0e57ff7eee4ac71d923f970d15889ad4d50f97a9 (patch)
treee5a92c55af5366924bd40ae14b4bf12842239193 /modules/repository
parente84558b0931309cf1f4f2767bc47296483b9b3e1 (diff)
downloadgitea-0e57ff7eee4ac71d923f970d15889ad4d50f97a9.tar.gz
gitea-0e57ff7eee4ac71d923f970d15889ad4d50f97a9.zip
Add generic set type (#21408)
This PR adds a generic set type to get rid of maps used as sets. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules/repository')
-rw-r--r--modules/repository/repo.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index 48c3edf60f..b01be322d2 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -18,6 +18,7 @@ import (
"code.gitea.io/gitea/models/organization"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/log"
@@ -275,7 +276,7 @@ func SyncReleasesWithTags(repo *repo_model.Repository, gitRepo *git.Repository)
return pullMirrorReleaseSync(repo, gitRepo)
}
- existingRelTags := make(map[string]struct{})
+ existingRelTags := make(container.Set[string])
opts := repo_model.FindReleasesOptions{
IncludeDrafts: true,
IncludeTags: true,
@@ -303,14 +304,14 @@ func SyncReleasesWithTags(repo *repo_model.Repository, gitRepo *git.Repository)
return fmt.Errorf("unable to PushUpdateDeleteTag: %q in Repo[%d:%s/%s]: %w", rel.TagName, repo.ID, repo.OwnerName, repo.Name, err)
}
} else {
- existingRelTags[strings.ToLower(rel.TagName)] = struct{}{}
+ existingRelTags.Add(strings.ToLower(rel.TagName))
}
}
}
_, err := gitRepo.WalkReferences(git.ObjectTag, 0, 0, func(sha1, refname string) error {
tagName := strings.TrimPrefix(refname, git.TagPrefix)
- if _, ok := existingRelTags[strings.ToLower(tagName)]; ok {
+ if existingRelTags.Contains(strings.ToLower(tagName)) {
return nil
}