aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2023-03-02 01:44:23 +0200
committerGitHub <noreply@github.com>2023-03-02 01:44:23 +0200
commit58b414380371a4419f909491700673d43ae6b4ff (patch)
tree9d994ac5afecdf2109fe93d9ba97a12c201bd27e /services
parentde6c718b46ebd3b7f6362c766eed328044d95ec7 (diff)
downloadgitea-58b414380371a4419f909491700673d43ae6b4ff.tar.gz
gitea-58b414380371a4419f909491700673d43ae6b4ff.zip
Add loading yaml label template files (#22976)
Extract from #11669 and enhancement to #22585 to support exclusive scoped labels in label templates * Move label template functionality to label module * Fix handling of color codes * Add Advanced label template
Diffstat (limited to 'services')
-rw-r--r--services/migrations/gitea_uploader.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go
index 20370d99f9..8b259a362b 100644
--- a/services/migrations/gitea_uploader.go
+++ b/services/migrations/gitea_uploader.go
@@ -21,6 +21,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
+ "code.gitea.io/gitea/modules/label"
"code.gitea.io/gitea/modules/log"
base "code.gitea.io/gitea/modules/migration"
repo_module "code.gitea.io/gitea/modules/repository"
@@ -217,18 +218,20 @@ func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) err
// CreateLabels creates labels
func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error {
lbs := make([]*issues_model.Label, 0, len(labels))
- for _, label := range labels {
- // We must validate color here:
- if !issues_model.LabelColorPattern.MatchString("#" + label.Color) {
- log.Warn("Invalid label color: #%s for label: %s in migration to %s/%s", label.Color, label.Name, g.repoOwner, g.repoName)
- label.Color = "ffffff"
+ for _, l := range labels {
+ if color, err := label.NormalizeColor(l.Color); err != nil {
+ log.Warn("Invalid label color: #%s for label: %s in migration to %s/%s", l.Color, l.Name, g.repoOwner, g.repoName)
+ l.Color = "#ffffff"
+ } else {
+ l.Color = color
}
lbs = append(lbs, &issues_model.Label{
RepoID: g.repo.ID,
- Name: label.Name,
- Description: label.Description,
- Color: "#" + label.Color,
+ Name: l.Name,
+ Exclusive: l.Exclusive,
+ Description: l.Description,
+ Color: l.Color,
})
}