Skip to content

Commit e5a5af2

Browse files
Merge pull request #93 from aman-harness/master
[CI-0]: Added Pr in issue
2 parents 0b916b6 + 199eee1 commit e5a5af2

File tree

5 files changed

+94
-76
lines changed

5 files changed

+94
-76
lines changed

scm/driver/github/issue.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ func (s *issueService) Unlock(ctx context.Context, repo string, number int) (*sc
9191
}
9292

9393
type issue struct {
94-
ID int `json:"id"`
95-
HTMLURL string `json:"html_url"`
96-
Number int `json:"number"`
97-
State string `json:"state"`
98-
Title string `json:"title"`
99-
Body string `json:"body"`
100-
User struct {
94+
ID int `json:"id"`
95+
HTMLURL string `json:"html_url"`
96+
Number int `json:"number"`
97+
State string `json:"state"`
98+
Title string `json:"title"`
99+
Body string `json:"body"`
100+
PullRequest pr `json:"pull_request"`
101+
User struct {
101102
Login string `json:"login"`
102103
AvatarURL string `json:"avatar_url"`
103104
} `json:"user"`
@@ -150,6 +151,10 @@ func convertIssue(from *issue) *scm.Issue {
150151
Body: from.Body,
151152
Link: from.HTMLURL,
152153
Labels: convertLabels(from),
154+
PullRequest: scm.PullRequest{
155+
Diff: from.PullRequest.DiffURL,
156+
Link: from.PullRequest.HTMLURL,
157+
},
153158
Locked: from.Locked,
154159
Closed: from.State == "closed",
155160
Author: scm.User{

scm/driver/github/testdata/issue.json.golden

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@
1515
"Avatar": "https://github.com/images/error/octocat_happy.gif"
1616
},
1717
"Created": "2011-04-22T13:33:48Z",
18-
"Updated": "2011-04-22T13:33:48Z"
19-
}
18+
"Updated": "2011-04-22T13:33:48Z",
19+
"PullRequest": {
20+
"Link": "https://github.com/octocat/Hello-World/pull/1347",
21+
"Diff": "https://github.com/octocat/Hello-World/pull/1347.diff"
22+
}
23+
}

scm/driver/github/testdata/issues.json.golden

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"Avatar": "https://github.com/images/error/octocat_happy.gif"
1717
},
1818
"Created": "2011-04-22T13:33:48Z",
19-
"Updated": "2011-04-22T13:33:48Z"
19+
"Updated": "2011-04-22T13:33:48Z",
20+
"PullRequest": {
21+
"Link": "https://github.com/octocat/Hello-World/pull/1347",
22+
"Diff": "https://github.com/octocat/Hello-World/pull/1347.diff"
23+
}
2024
}
2125
]
Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,62 @@
11
{
2-
"Action": "created",
3-
"Repo": {
4-
"ID": "309651765",
5-
"Namespace": "abc",
6-
"Name": "def-ci-webhook-test",
7-
"Perm": null,
8-
"Branch": "master",
9-
"Private": true,
10-
"Visibility": 0,
11-
"Clone": "https://github.com/abc/def-ci-webhook-test.git",
12-
"CloneSSH": "[email protected]:abc/def-ci-webhook-test.git",
13-
"Link": "https://github.com/abc/def-ci-webhook-test",
14-
"Created": "0001-01-01T00:00:00Z",
15-
"Updated": "0001-01-01T00:00:00Z"
16-
},
17-
"Issue": {
18-
"Number": 2,
19-
"Title": "Update README.md",
20-
"Body": "",
21-
"Link": "https://github.com/abc/def-ci-webhook-test/pull/2",
22-
"Labels": null,
23-
"Closed": false,
24-
"Locked": false,
25-
"Author": {
26-
"Login": "lts-def",
27-
"Name": "",
28-
"Email": "",
29-
"Avatar": "https://avatars0.githubusercontent.com/u/10278482?v=4",
30-
"Created": "0001-01-01T00:00:00Z",
31-
"Updated": "0001-01-01T00:00:00Z"
32-
},
33-
"Created": "2020-11-03T22:32:14Z",
34-
"Updated": "2020-12-29T05:49:14Z"
35-
},
36-
"Comment": {
37-
"ID": 751955664,
38-
"Body": "trigger abc",
39-
"Author": {
40-
"Login": "lts-def",
41-
"Name": "",
42-
"Email": "",
43-
"Avatar": "https://avatars0.githubusercontent.com/u/10278482?v=4",
44-
"Created": "0001-01-01T00:00:00Z",
45-
"Updated": "0001-01-01T00:00:00Z"
46-
},
47-
"Created": "2020-12-29T05:49:14Z",
48-
"Updated": "2020-12-29T05:49:14Z"
49-
},
50-
"Sender": {
51-
"Login": "lts-def",
52-
"Name": "",
53-
"Email": "",
54-
"Avatar": "https://avatars0.githubusercontent.com/u/10278482?v=4",
55-
"Created": "0001-01-01T00:00:00Z",
56-
"Updated": "0001-01-01T00:00:00Z"
57-
}
2+
"Action":"created",
3+
"Repo":{
4+
"ID":"309651765",
5+
"Namespace":"abc",
6+
"Name":"def-ci-webhook-test",
7+
"Perm":null,
8+
"Branch":"master",
9+
"Private":true,
10+
"Visibility":0,
11+
"Clone":"https://github.com/abc/def-ci-webhook-test.git",
12+
"CloneSSH":"[email protected]:abc/def-ci-webhook-test.git",
13+
"Link":"https://github.com/abc/def-ci-webhook-test",
14+
"Created":"0001-01-01T00:00:00Z",
15+
"Updated":"0001-01-01T00:00:00Z"
16+
},
17+
"Issue":{
18+
"Number":2,
19+
"Title":"Update README.md",
20+
"Body":"",
21+
"Link":"https://github.com/abc/def-ci-webhook-test/pull/2",
22+
"Labels":null,
23+
"Closed":false,
24+
"Locked":false,
25+
"Author":{
26+
"Login":"lts-def",
27+
"Name":"",
28+
"Email":"",
29+
"Avatar":"https://avatars0.githubusercontent.com/u/10278482?v=4",
30+
"Created":"0001-01-01T00:00:00Z",
31+
"Updated":"0001-01-01T00:00:00Z"
32+
},
33+
"PullRequest":{
34+
"Link":"https://github.com/abc/def-ci-webhook-test/pull/2",
35+
"Diff":"https://github.com/abc/def-ci-webhook-test/pull/2.diff"
36+
},
37+
"Created":"2020-11-03T22:32:14Z",
38+
"Updated":"2020-12-29T05:49:14Z"
39+
},
40+
"Comment":{
41+
"ID":751955664,
42+
"Body":"trigger abc",
43+
"Author":{
44+
"Login":"lts-def",
45+
"Name":"",
46+
"Email":"",
47+
"Avatar":"https://avatars0.githubusercontent.com/u/10278482?v=4",
48+
"Created":"0001-01-01T00:00:00Z",
49+
"Updated":"0001-01-01T00:00:00Z"
50+
},
51+
"Created":"2020-12-29T05:49:14Z",
52+
"Updated":"2020-12-29T05:49:14Z"
53+
},
54+
"Sender":{
55+
"Login":"lts-def",
56+
"Name":"",
57+
"Email":"",
58+
"Avatar":"https://avatars0.githubusercontent.com/u/10278482?v=4",
59+
"Created":"0001-01-01T00:00:00Z",
60+
"Updated":"0001-01-01T00:00:00Z"
61+
}
5862
}

scm/issue.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ import (
1212
type (
1313
// Issue represents an issue.
1414
Issue struct {
15-
Number int
16-
Title string
17-
Body string
18-
Link string
19-
Labels []string
20-
Closed bool
21-
Locked bool
22-
Author User
23-
Created time.Time
24-
Updated time.Time
15+
Number int
16+
Title string
17+
Body string
18+
Link string
19+
Labels []string
20+
Closed bool
21+
Locked bool
22+
Author User
23+
PullRequest PullRequest
24+
Created time.Time
25+
Updated time.Time
2526
}
2627

2728
// IssueInput provides the input fields required for

0 commit comments

Comments
 (0)