Skip to content

Commit

Permalink
Add color field to label struct
Browse files Browse the repository at this point in the history
  • Loading branch information
takirala committed Aug 19, 2020
1 parent 23aa7d5 commit 1ccff59
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions scm/driver/gitea/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ type pr struct {
Created time.Time `json:"created_at"`
Updated time.Time `json:"updated_at"`
Labels []struct {
Name string `json:"name"`
Name string `json:"name"`
Color string `json:"color"`
} `json:"labels"`
}

Expand Down Expand Up @@ -129,7 +130,8 @@ func convertPullRequest(src *pr) *scm.PullRequest {
var labels []scm.Label
for _, label := range src.Labels {
labels = append(labels, scm.Label{
Name: label.Name,
Name: label.Name,
Color: label.Color,
})
}
return &scm.PullRequest{
Expand Down
6 changes: 4 additions & 2 deletions scm/driver/github/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ type pr struct {
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Labels []struct {
Name string `json:"name"`
Name string `json:"name"`
Color string `json:"color"`
} `json:"labels"`
}

Expand Down Expand Up @@ -129,7 +130,8 @@ func convertPullRequest(from *pr) *scm.PullRequest {
var labels []scm.Label
for _, label := range from.Labels {
labels = append(labels, scm.Label{
Name: label.Name,
Name: label.Name,
Color: label.Color,
})
}
return &scm.PullRequest{
Expand Down
2 changes: 1 addition & 1 deletion scm/driver/github/testdata/webhooks/pr_labeled.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"node_id": "MDU6TGFiZWw2MzA2MzQ4MA==",
"url": "https://api.github.com/repos/bradrydzewski/drone-test-go/labels/bug",
"name": "bug",
"color": "fc2929",
"color": "fc2927",
"default": true
},
{
Expand Down
6 changes: 4 additions & 2 deletions scm/driver/github/testdata/webhooks/pr_labeled.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@
"Updated": "2018-06-25T19:05:03Z",
"labels": [
{
"name": "bug"
"name": "bug",
"color": "fc2927"
},
{
"name": "documentation"
"name": "documentation",
"color": "fc2929"
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion scm/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ type (
}

Label struct {
Name string
Name string
Color string
}

// PullRequestService provides access to pull request resources.
Expand Down

0 comments on commit 1ccff59

Please sign in to comment.