summaryrefslogtreecommitdiffstats
path: root/modules/migrations
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-09-10 15:04:30 +0200
committerGitHub <noreply@github.com>2020-09-10 14:04:30 +0100
commite10327168d0f0a4942bbfea8fedf3d2d1b04f09c (patch)
tree5935e766d2ed69641780be2c70becef9b71eafc7 /modules/migrations
parent0db9043aa76db098bcb4b962674bc9ca92fc84c9 (diff)
downloadgitea-e10327168d0f0a4942bbfea8fedf3d2d1b04f09c.tar.gz
gitea-e10327168d0f0a4942bbfea8fedf3d2d1b04f09c.zip
GitLab DL: normalizeColor (#12793)
Diffstat (limited to 'modules/migrations')
-rw-r--r--modules/migrations/gitlab.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/modules/migrations/gitlab.go b/modules/migrations/gitlab.go
index 33ccc4dcad..13d2618030 100644
--- a/modules/migrations/gitlab.go
+++ b/modules/migrations/gitlab.go
@@ -215,6 +215,19 @@ func (g *GitlabDownloader) GetMilestones() ([]*base.Milestone, error) {
return milestones, nil
}
+func (g *GitlabDownloader) normalizeColor(val string) string {
+ val = strings.TrimLeft(val, "#")
+ val = strings.ToLower(val)
+ if len(val) == 3 {
+ c := []rune(val)
+ val = fmt.Sprintf("%c%c%c%c%c%c", c[0], c[0], c[1], c[1], c[2], c[2])
+ }
+ if len(val) != 6 {
+ return ""
+ }
+ return val
+}
+
// GetLabels returns labels
func (g *GitlabDownloader) GetLabels() ([]*base.Label, error) {
var perPage = 100
@@ -230,7 +243,7 @@ func (g *GitlabDownloader) GetLabels() ([]*base.Label, error) {
for _, label := range ls {
baseLabel := &base.Label{
Name: label.Name,
- Color: strings.TrimLeft(label.Color, "#)"),
+ Color: g.normalizeColor(label.Color),
Description: label.Description,
}
labels = append(labels, baseLabel)