Skip to content

Commit

Permalink
feat: allow std hex colors
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
  • Loading branch information
shanduur committed Jul 30, 2023
1 parent 596cf85 commit a4f91d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions cmd/labeler/upload/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ func TestPostLabel(t *testing.T) {
Repo: testRepo,
Cassette: govcr.NewCassetteLoader(fixtures),
},
{
Name: "with_prefix",
Label: labels.Label{
Name: testLabelName,
Color: "#" + testLabelColor,
Description: &testLabelDescription,
},
Owner: testOwner,
Repo: testRepo,
Cassette: govcr.NewCassetteLoader(fixtures),
},
} {
t.Run(tc.Name, func(t *testing.T) {
tc := tc
Expand Down
8 changes: 7 additions & 1 deletion labels/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package labels

import (
"errors"
"strings"

"github.com/google/go-github/v53/github"
)
Expand All @@ -25,9 +26,14 @@ func (l *Label) Validate() error {
}

func (l *Label) ToGitHub() *github.Label {
color := l.Color
if strings.HasPrefix(l.Color, "#") {
color = strings.TrimPrefix(color, "#")
}

return &github.Label{
Name: &l.Name,
Color: &l.Color,
Color: &color,
Description: l.Description,
}
}
Expand Down

0 comments on commit a4f91d9

Please sign in to comment.