Skip to content

Commit e103271

Browse files
authored
GitLab DL: normalizeColor (#12793)
1 parent 0db9043 commit e103271

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

modules/migrations/gitlab.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,19 @@ func (g *GitlabDownloader) GetMilestones() ([]*base.Milestone, error) {
215215
return milestones, nil
216216
}
217217

218+
func (g *GitlabDownloader) normalizeColor(val string) string {
219+
val = strings.TrimLeft(val, "#")
220+
val = strings.ToLower(val)
221+
if len(val) == 3 {
222+
c := []rune(val)
223+
val = fmt.Sprintf("%c%c%c%c%c%c", c[0], c[0], c[1], c[1], c[2], c[2])
224+
}
225+
if len(val) != 6 {
226+
return ""
227+
}
228+
return val
229+
}
230+
218231
// GetLabels returns labels
219232
func (g *GitlabDownloader) GetLabels() ([]*base.Label, error) {
220233
var perPage = 100
@@ -230,7 +243,7 @@ func (g *GitlabDownloader) GetLabels() ([]*base.Label, error) {
230243
for _, label := range ls {
231244
baseLabel := &base.Label{
232245
Name: label.Name,
233-
Color: strings.TrimLeft(label.Color, "#)"),
246+
Color: g.normalizeColor(label.Color),
234247
Description: label.Description,
235248
}
236249
labels = append(labels, baseLabel)

0 commit comments

Comments
 (0)