Skip to content

Commit be8e076

Browse files
Merge pull request #489 from kmdrn7/feat/hook-pr-deleted-stash
feat: handle webhook event pr:deleted for stash
2 parents 40e4a13 + f616b05 commit be8e076

File tree

7 files changed

+97
-4
lines changed

7 files changed

+97
-4
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ issues:
109109
- cmd/docs
110110

111111
run:
112-
timeout: 30m
112+
timeout: 4h
113113
# golangci.com configuration
114114
# https://github.com/golangci/golangci/wiki/Configuration

.lighthouse/jenkins-x/lint.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ spec:
88
tasks:
99
- name: go-scm-lint
1010
resources: {}
11+
timeout: 24h
1112
taskSpec:
1213
metadata: {}
1314
stepTemplate:
@@ -23,5 +24,5 @@ spec:
2324
resources: {}
2425
podTemplate: {}
2526
serviceAccountName: tekton-bot
26-
timeout: 30m0s
27+
timeout: 24h
2728
status: {}

.lighthouse/jenkins-x/pullrequest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ spec:
77
pipelineSpec:
88
tasks:
99
- name: from-build-pack
10+
timeout: 24h
1011
resources: {}
1112
taskSpec:
1213
metadata: {}

.lighthouse/jenkins-x/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ spec:
66
pipelineSpec:
77
tasks:
88
- name: from-build-pack
9+
timeout: 24h
910
taskSpec:
1011
stepTemplate:
1112
image: uses:jenkins-x/jx3-pipeline-catalog/tasks/go/release.yaml@versionStream
Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,81 @@
1-
{}
1+
{
2+
"Action": "deleted",
3+
"Repo": {
4+
"ID": "1",
5+
"Namespace": "PRJ",
6+
"Name": "my-repo",
7+
"FullName": "PRJ/my-repo",
8+
"Perm": null,
9+
"Branch": "master",
10+
"Private": true,
11+
"Clone": "",
12+
"CloneSSH": "",
13+
"Link": "",
14+
"Created": "0001-01-01T00:00:00Z",
15+
"Updated": "0001-01-01T00:00:00Z"
16+
},
17+
"PullRequest": {
18+
"Number": 2,
19+
"Title": "added LICENSE",
20+
"Body": "added BSD license text",
21+
"Sha": "b9eaed50a03c073b20dfa82e5e753d295e7f0e56",
22+
"Ref": "refs/pull-requests/2/from",
23+
"Source": "develop",
24+
"Target": "master",
25+
"Fork": "PRJ/my-repo",
26+
"Link": "",
27+
"Closed": true,
28+
"Merged": false,
29+
"State": "declined",
30+
"Base": {
31+
"Ref": "master",
32+
"Sha": "823b2230a56056231c9425d63758fa87078a66b4",
33+
"Repo": {
34+
"ID": "1",
35+
"Namespace": "PRJ",
36+
"Name": "my-repo",
37+
"FullName": "PRJ/my-repo",
38+
"Perm": null,
39+
"Branch": "master",
40+
"Private": true,
41+
"Clone": "",
42+
"CloneSSH": "",
43+
"Link": "",
44+
"Created": "0001-01-01T00:00:00Z",
45+
"Updated": "0001-01-01T00:00:00Z"
46+
}
47+
},
48+
"Head": {
49+
"Ref": "develop",
50+
"Sha": "b9eaed50a03c073b20dfa82e5e753d295e7f0e56",
51+
"Repo": {
52+
"ID": "1",
53+
"Namespace": "PRJ",
54+
"Name": "my-repo",
55+
"FullName": "PRJ/my-repo",
56+
"Perm": null,
57+
"Branch": "master",
58+
"Private": true,
59+
"Clone": "",
60+
"CloneSSH": "",
61+
"Link": "",
62+
"Created": "0001-01-01T00:00:00Z",
63+
"Updated": "0001-01-01T00:00:00Z"
64+
}
65+
},
66+
"Author": {
67+
"Login": "jcitizen",
68+
"Name": "Jane Citizen",
69+
"Email": "[email protected]",
70+
"Avatar": "https://www.gravatar.com/avatar/9e26471d35a78862c17e467d87cddedf.jpg"
71+
},
72+
"Created": "2018-07-05T12:21:30-07:00",
73+
"Updated": "2018-07-05T12:30:48-07:00"
74+
},
75+
"Sender": {
76+
"Login": "jcitizen",
77+
"Name": "Jane Citizen",
78+
"Email": "[email protected]",
79+
"Avatar": "https://www.gravatar.com/avatar/9e26471d35a78862c17e467d87cddedf.jpg"
80+
}
81+
}

scm/driver/stash/webhook.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (s *webhookService) Parse(req *http.Request, fn scm.SecretFunc) (scm.Webhoo
4646
switch event {
4747
case "repo:refs_changed":
4848
hook, err = s.parsePushHook(data, guid)
49-
case "pr:opened", "pr:declined", "pr:merged", "pr:from_ref_updated", "pr:modified":
49+
case "pr:opened", "pr:declined", "pr:deleted", "pr:merged", "pr:from_ref_updated", "pr:modified":
5050
hook, err = s.parsePullRequest(data)
5151
case "pr:comment:added", "pr:comment:edited":
5252
hook, err = s.parsePullRequestComment(data, guid)
@@ -114,6 +114,8 @@ func (s *webhookService) parsePullRequest(data []byte) (scm.Webhook, error) {
114114
dst.Action = scm.ActionOpen
115115
case "pr:declined":
116116
dst.Action = scm.ActionClose
117+
case "pr:deleted":
118+
dst.Action = scm.ActionDelete
117119
case "pr:merged":
118120
dst.Action = scm.ActionMerge
119121
case "pr:from_ref_updated":

scm/driver/stash/webhook_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ func TestWebhooks(t *testing.T) {
123123
after: "testdata/webhooks/pr_declined.json.golden",
124124
obj: new(scm.PullRequestHook),
125125
},
126+
// pull request deleted
127+
{
128+
sig: "71295b197fa25f4356d2fb9965df3f2379d903d7",
129+
event: "pr:deleted",
130+
before: "testdata/webhooks/pr_deleted.json",
131+
after: "testdata/webhooks/pr_deleted.json.golden",
132+
obj: new(scm.PullRequestHook),
133+
},
126134
// pull request comment
127135
{
128136
sig: "71295b197fa25f4356d2fb9965df3f2379d903d7",

0 commit comments

Comments
 (0)