Skip to content

Commit

Permalink
Merge pull request #93 from aman-harness/master
Browse files Browse the repository at this point in the history
[CI-0]: Added Pr in issue
  • Loading branch information
bradrydzewski authored Jan 11, 2021
2 parents 0b916b6 + 199eee1 commit e5a5af2
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 76 deletions.
19 changes: 12 additions & 7 deletions scm/driver/github/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ func (s *issueService) Unlock(ctx context.Context, repo string, number int) (*sc
}

type issue struct {
ID int `json:"id"`
HTMLURL string `json:"html_url"`
Number int `json:"number"`
State string `json:"state"`
Title string `json:"title"`
Body string `json:"body"`
User struct {
ID int `json:"id"`
HTMLURL string `json:"html_url"`
Number int `json:"number"`
State string `json:"state"`
Title string `json:"title"`
Body string `json:"body"`
PullRequest pr `json:"pull_request"`
User struct {
Login string `json:"login"`
AvatarURL string `json:"avatar_url"`
} `json:"user"`
Expand Down Expand Up @@ -150,6 +151,10 @@ func convertIssue(from *issue) *scm.Issue {
Body: from.Body,
Link: from.HTMLURL,
Labels: convertLabels(from),
PullRequest: scm.PullRequest{
Diff: from.PullRequest.DiffURL,
Link: from.PullRequest.HTMLURL,
},
Locked: from.Locked,
Closed: from.State == "closed",
Author: scm.User{
Expand Down
8 changes: 6 additions & 2 deletions scm/driver/github/testdata/issue.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"Avatar": "https://github.com/images/error/octocat_happy.gif"
},
"Created": "2011-04-22T13:33:48Z",
"Updated": "2011-04-22T13:33:48Z"
}
"Updated": "2011-04-22T13:33:48Z",
"PullRequest": {
"Link": "https://github.com/octocat/Hello-World/pull/1347",
"Diff": "https://github.com/octocat/Hello-World/pull/1347.diff"
}
}
6 changes: 5 additions & 1 deletion scm/driver/github/testdata/issues.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"Avatar": "https://github.com/images/error/octocat_happy.gif"
},
"Created": "2011-04-22T13:33:48Z",
"Updated": "2011-04-22T13:33:48Z"
"Updated": "2011-04-22T13:33:48Z",
"PullRequest": {
"Link": "https://github.com/octocat/Hello-World/pull/1347",
"Diff": "https://github.com/octocat/Hello-World/pull/1347.diff"
}
}
]
116 changes: 60 additions & 56 deletions scm/driver/github/testdata/webhooks/comment.json.golden
Original file line number Diff line number Diff line change
@@ -1,58 +1,62 @@
{
"Action": "created",
"Repo": {
"ID": "309651765",
"Namespace": "abc",
"Name": "def-ci-webhook-test",
"Perm": null,
"Branch": "master",
"Private": true,
"Visibility": 0,
"Clone": "https://github.com/abc/def-ci-webhook-test.git",
"CloneSSH": "[email protected]:abc/def-ci-webhook-test.git",
"Link": "https://github.com/abc/def-ci-webhook-test",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Issue": {
"Number": 2,
"Title": "Update README.md",
"Body": "",
"Link": "https://github.com/abc/def-ci-webhook-test/pull/2",
"Labels": null,
"Closed": false,
"Locked": false,
"Author": {
"Login": "lts-def",
"Name": "",
"Email": "",
"Avatar": "https://avatars0.githubusercontent.com/u/10278482?v=4",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Created": "2020-11-03T22:32:14Z",
"Updated": "2020-12-29T05:49:14Z"
},
"Comment": {
"ID": 751955664,
"Body": "trigger abc",
"Author": {
"Login": "lts-def",
"Name": "",
"Email": "",
"Avatar": "https://avatars0.githubusercontent.com/u/10278482?v=4",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Created": "2020-12-29T05:49:14Z",
"Updated": "2020-12-29T05:49:14Z"
},
"Sender": {
"Login": "lts-def",
"Name": "",
"Email": "",
"Avatar": "https://avatars0.githubusercontent.com/u/10278482?v=4",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
}
"Action":"created",
"Repo":{
"ID":"309651765",
"Namespace":"abc",
"Name":"def-ci-webhook-test",
"Perm":null,
"Branch":"master",
"Private":true,
"Visibility":0,
"Clone":"https://github.com/abc/def-ci-webhook-test.git",
"CloneSSH":"[email protected]:abc/def-ci-webhook-test.git",
"Link":"https://github.com/abc/def-ci-webhook-test",
"Created":"0001-01-01T00:00:00Z",
"Updated":"0001-01-01T00:00:00Z"
},
"Issue":{
"Number":2,
"Title":"Update README.md",
"Body":"",
"Link":"https://github.com/abc/def-ci-webhook-test/pull/2",
"Labels":null,
"Closed":false,
"Locked":false,
"Author":{
"Login":"lts-def",
"Name":"",
"Email":"",
"Avatar":"https://avatars0.githubusercontent.com/u/10278482?v=4",
"Created":"0001-01-01T00:00:00Z",
"Updated":"0001-01-01T00:00:00Z"
},
"PullRequest":{
"Link":"https://github.com/abc/def-ci-webhook-test/pull/2",
"Diff":"https://github.com/abc/def-ci-webhook-test/pull/2.diff"
},
"Created":"2020-11-03T22:32:14Z",
"Updated":"2020-12-29T05:49:14Z"
},
"Comment":{
"ID":751955664,
"Body":"trigger abc",
"Author":{
"Login":"lts-def",
"Name":"",
"Email":"",
"Avatar":"https://avatars0.githubusercontent.com/u/10278482?v=4",
"Created":"0001-01-01T00:00:00Z",
"Updated":"0001-01-01T00:00:00Z"
},
"Created":"2020-12-29T05:49:14Z",
"Updated":"2020-12-29T05:49:14Z"
},
"Sender":{
"Login":"lts-def",
"Name":"",
"Email":"",
"Avatar":"https://avatars0.githubusercontent.com/u/10278482?v=4",
"Created":"0001-01-01T00:00:00Z",
"Updated":"0001-01-01T00:00:00Z"
}
}
21 changes: 11 additions & 10 deletions scm/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ import (
type (
// Issue represents an issue.
Issue struct {
Number int
Title string
Body string
Link string
Labels []string
Closed bool
Locked bool
Author User
Created time.Time
Updated time.Time
Number int
Title string
Body string
Link string
Labels []string
Closed bool
Locked bool
Author User
PullRequest PullRequest
Created time.Time
Updated time.Time
}

// IssueInput provides the input fields required for
Expand Down

0 comments on commit e5a5af2

Please sign in to comment.