forked from harness/gitness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.go
162 lines (156 loc) · 4.48 KB
/
hooks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package fixtures
// HookPush is a sample push hook.
// https://developer.github.com/v3/activity/events/types/#pushevent
const HookPush = `
{
"ref": "refs/heads/changes",
"created": false,
"deleted": false,
"head_commit": {
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
}
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"private": false,
"html_url": "https://github.com/baxterthehacker/public-repo",
"default_branch": "master"
},
"pusher": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"sender": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
}
}
`
// HookPush is a sample push hook that is marked as deleted, and is expected to
// be ignored.
const HookPushDeleted = `
{
"deleted": true
}
`
// HookPullRequest is a sample hook pull request
// https://developer.github.com/v3/activity/events/types/#pullrequestevent
const HookPullRequest = `
{
"action": "opened",
"number": 1,
"pull_request": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1",
"html_url": "https://github.com/baxterthehacker/public-repo/pull/1",
"number": 1,
"state": "open",
"title": "Update the README with new information",
"user": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
},
"base": {
"label": "baxterthehacker:master",
"ref": "master",
"sha": "9353195a19e45482665306e466c832c46560532d"
},
"head": {
"label": "baxterthehacker:changes",
"ref": "changes",
"sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c"
}
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
},
"private": true,
"html_url": "https://github.com/baxterthehacker/public-repo",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"default_branch": "master"
},
"sender": {
"login": "octocat",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
}
}
`
// HookPullRequestInvalidAction is a sample hook pull request that has an
// action not equal to synchrize or opened, and is expected to be ignored.
const HookPullRequestInvalidAction = `
{
"action": "reopened",
"number": 1
}
`
// HookPullRequestInvalidState is a sample hook pull request that has a state
// not equal to open, and is expected to be ignored.
const HookPullRequestInvalidState = `
{
"action": "synchronize",
"pull_request": {
"number": 1,
"state": "closed"
}
}
`
// HookPush is a sample deployment hook.
// https://developer.github.com/v3/activity/events/types/#deploymentevent
const HookDeploy = `
{
"deployment": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments/710692",
"id": 710692,
"sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
"ref": "master",
"task": "deploy",
"payload": {
},
"environment": "production",
"description": null,
"creator": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
}
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
},
"private": true,
"html_url": "https://github.com/baxterthehacker/public-repo",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"default_branch": "master"
},
"sender": {
"login": "baxterthehacker",
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3"
}
}
`