Skip to content

Commit

Permalink
Migration Tool: Backport GitLab Label Color Normalizer (#12793) (#13100)
Browse files Browse the repository at this point in the history
fix bug mentioned in #13085

backport of #12793
  • Loading branch information
6543 authored Oct 11, 2020
1 parent 2bd7fee commit e1ed2a7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion modules/migrations/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,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) {
if g == nil {
Expand All @@ -259,7 +272,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)
Expand Down

0 comments on commit e1ed2a7

Please sign in to comment.