Skip to content

Commit

Permalink
Add labels to GitHub PullRequest.
Browse files Browse the repository at this point in the history
  • Loading branch information
wlynch committed Aug 21, 2019
1 parent b46cc31 commit 2e78367
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions scm/driver/github/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type pr struct {
State string `json:"state"`
Title string `json:"title"`
Body string `json:"body"`
Labels []*label `json:"labels"`
DiffURL string `json:"diff_url"`
User user `json:"user"`
RequestedReviewers []user `json:"requested_reviewers"`
Expand Down Expand Up @@ -101,6 +102,7 @@ func convertPullRequest(from *pr) *scm.PullRequest {
Number: from.Number,
Title: from.Title,
Body: from.Body,
Labels: convertLabelObjects(from.Labels),
Sha: from.Head.Sha,
Ref: fmt.Sprintf("refs/pull/%d/head", from.Number),
State: from.State,
Expand Down
13 changes: 12 additions & 1 deletion scm/driver/github/testdata/pr.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
"state": "open",
"title": "new-feature",
"body": "Please pull these awesome changes",
"labels": [
{
"id": 208045946,
"node_id": "MDU6TGFiZWwyMDgwNDU5NDY=",
"url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"name": "bug",
"description": "Something isn't working",
"color": "f29513",
"default": true
}
],
"assignee": {
"login": "octocat",
"id": 1,
Expand Down Expand Up @@ -398,4 +409,4 @@
"deletions": 3,
"changed_files": 5,
"maintainer_can_modify": true
}
}
10 changes: 9 additions & 1 deletion scm/driver/github/testdata/pr.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
"Number": 1347,
"Title": "new-feature",
"Body": "Please pull these awesome changes",
"Labels": [
{
"Url": "https://api.github.com/repos/octocat/Hello-World/labels/bug",
"Name": "bug",
"Description": "Something isn't working",
"Color": "f29513"
}
],
"Sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"Ref": "refs/pull/1347/head",
"Source": "new-topic",
Expand Down Expand Up @@ -59,4 +67,4 @@
},
"Created": "2011-01-26T19:01:12Z",
"Updated": "2011-01-26T19:01:12Z"
}
}
9 changes: 8 additions & 1 deletion scm/driver/github/testdata/webhooks/pr_labeled.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"Number": 1,
"Title": "Update .drone.yml",
"Body": "",
"Labels": [
{
"Name": "bug",
"Color": "fc2929",
"URL": "https://api.github.com/repos/bradrydzewski/drone-test-go/labels/bug"
}
],
"Sha": "d2b75aa7797ec26b088fa2dd527e9d2c052fcedd",
"Ref": "refs/pull/1/head",
"Source": "master",
Expand Down Expand Up @@ -93,4 +100,4 @@
"Avatar": "https://avatars1.githubusercontent.com/u/817538?v=4"
},
"GUID": "f2467dea-70d6-11e8-8955-3c83993e0aef"
}
}
1 change: 1 addition & 0 deletions scm/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type (
Number int
Title string
Body string
Labels []*Label
Sha string
Ref string
Source string
Expand Down

0 comments on commit 2e78367

Please sign in to comment.