@@ -92,47 +92,44 @@ func getIssuesCommentInfo(p *api.IssueCommentPayload) (title, link, by, operator
92
92
}
93
93
94
94
func getIssuesPayloadInfo (p * api.IssuePayload , linkFormatter linkFormatter , withSender bool ) (string , string , string , int ) {
95
- repoLink := linkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
96
95
issueTitle := fmt .Sprintf ("#%d %s" , p .Index , p .Issue .Title )
97
96
titleLink := linkFormatter (fmt .Sprintf ("%s/issues/%d" , p .Repository .HTMLURL , p .Index ), issueTitle )
98
97
var text string
99
98
color := yellowColor
100
99
101
100
switch p .Action {
102
101
case api .HookIssueOpened :
103
- text = fmt .Sprintf ("[%s] Issue opened: %s" , repoLink , titleLink )
102
+ text = fmt .Sprintf ("[%s] Issue opened: %s" , p . Repository . FullName , titleLink )
104
103
color = orangeColor
105
104
case api .HookIssueClosed :
106
- text = fmt .Sprintf ("[%s] Issue closed: %s" , repoLink , titleLink )
105
+ text = fmt .Sprintf ("[%s] Issue closed: %s" , p . Repository . FullName , titleLink )
107
106
color = redColor
108
107
case api .HookIssueReOpened :
109
- text = fmt .Sprintf ("[%s] Issue re-opened: %s" , repoLink , titleLink )
108
+ text = fmt .Sprintf ("[%s] Issue re-opened: %s" , p . Repository . FullName , titleLink )
110
109
case api .HookIssueEdited :
111
- text = fmt .Sprintf ("[%s] Issue edited: %s" , repoLink , titleLink )
110
+ text = fmt .Sprintf ("[%s] Issue edited: %s" , p . Repository . FullName , titleLink )
112
111
case api .HookIssueAssigned :
113
112
list := make ([]string , len (p .Issue .Assignees ))
114
113
for i , user := range p .Issue .Assignees {
115
114
list [i ] = linkFormatter (setting .AppURL + url .PathEscape (user .UserName ), user .UserName )
116
115
}
117
- text = fmt .Sprintf ("[%s] Issue assigned to %s: %s" , repoLink , strings .Join (list , ", " ), titleLink )
116
+ text = fmt .Sprintf ("[%s] Issue assigned to %s: %s" , p . Repository . FullName , strings .Join (list , ", " ), titleLink )
118
117
color = greenColor
119
118
case api .HookIssueUnassigned :
120
- text = fmt .Sprintf ("[%s] Issue unassigned: %s" , repoLink , titleLink )
119
+ text = fmt .Sprintf ("[%s] Issue unassigned: %s" , p . Repository . FullName , titleLink )
121
120
case api .HookIssueLabelUpdated :
122
- text = fmt .Sprintf ("[%s] Issue labels updated: %s" , repoLink , titleLink )
121
+ text = fmt .Sprintf ("[%s] Issue labels updated: %s" , p . Repository . FullName , titleLink )
123
122
case api .HookIssueLabelCleared :
124
- text = fmt .Sprintf ("[%s] Issue labels cleared: %s" , repoLink , titleLink )
123
+ text = fmt .Sprintf ("[%s] Issue labels cleared: %s" , p . Repository . FullName , titleLink )
125
124
case api .HookIssueSynchronized :
126
- text = fmt .Sprintf ("[%s] Issue synchronized: %s" , repoLink , titleLink )
125
+ text = fmt .Sprintf ("[%s] Issue synchronized: %s" , p . Repository . FullName , titleLink )
127
126
case api .HookIssueMilestoned :
128
- mileStoneLink := fmt .Sprintf ("%s/milestone/%d" , p .Repository .HTMLURL , p .Issue .Milestone .ID )
129
- text = fmt .Sprintf ("[%s] Issue milestoned to %s: %s" , repoLink ,
130
- linkFormatter (mileStoneLink , p .Issue .Milestone .Title ), titleLink )
127
+ text = fmt .Sprintf ("[%s] Issue milestoned to %s: %s" , p .Repository .FullName , p .Issue .Milestone .Title , titleLink )
131
128
case api .HookIssueDemilestoned :
132
- text = fmt .Sprintf ("[%s] Issue milestone cleared: %s" , repoLink , titleLink )
129
+ text = fmt .Sprintf ("[%s] Issue milestone cleared: %s" , p . Repository . FullName , titleLink )
133
130
}
134
131
if withSender {
135
- text += fmt .Sprintf (" by %s" , linkFormatter ( setting . AppURL + url . PathEscape ( p .Sender .UserName ), p . Sender . UserName ) )
132
+ text += fmt .Sprintf (" by %s" , p .Sender .UserName )
136
133
}
137
134
138
135
var attachmentText string
@@ -144,7 +141,6 @@ func getIssuesPayloadInfo(p *api.IssuePayload, linkFormatter linkFormatter, with
144
141
}
145
142
146
143
func getPullRequestPayloadInfo (p * api.PullRequestPayload , linkFormatter linkFormatter , withSender bool ) (string , string , string , int ) {
147
- repoLink := linkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
148
144
issueTitle := fmt .Sprintf ("#%d %s" , p .Index , p .PullRequest .Title )
149
145
titleLink := linkFormatter (p .PullRequest .URL , issueTitle )
150
146
var text string
@@ -153,96 +149,92 @@ func getPullRequestPayloadInfo(p *api.PullRequestPayload, linkFormatter linkForm
153
149
154
150
switch p .Action {
155
151
case api .HookIssueOpened :
156
- text = fmt .Sprintf ("[%s] Pull request opened: %s" , repoLink , titleLink )
152
+ text = fmt .Sprintf ("[%s] Pull request opened: %s" , p . Repository . FullName , titleLink )
157
153
attachmentText = p .PullRequest .Body
158
154
color = greenColor
159
155
case api .HookIssueClosed :
160
156
if p .PullRequest .HasMerged {
161
- text = fmt .Sprintf ("[%s] Pull request merged: %s" , repoLink , titleLink )
157
+ text = fmt .Sprintf ("[%s] Pull request merged: %s" , p . Repository . FullName , titleLink )
162
158
color = purpleColor
163
159
} else {
164
- text = fmt .Sprintf ("[%s] Pull request closed: %s" , repoLink , titleLink )
160
+ text = fmt .Sprintf ("[%s] Pull request closed: %s" , p . Repository . FullName , titleLink )
165
161
color = redColor
166
162
}
167
163
case api .HookIssueReOpened :
168
- text = fmt .Sprintf ("[%s] Pull request re-opened: %s" , repoLink , titleLink )
164
+ text = fmt .Sprintf ("[%s] Pull request re-opened: %s" , p . Repository . FullName , titleLink )
169
165
case api .HookIssueEdited :
170
- text = fmt .Sprintf ("[%s] Pull request edited: %s" , repoLink , titleLink )
166
+ text = fmt .Sprintf ("[%s] Pull request edited: %s" , p . Repository . FullName , titleLink )
171
167
attachmentText = p .PullRequest .Body
172
168
case api .HookIssueAssigned :
173
169
list := make ([]string , len (p .PullRequest .Assignees ))
174
170
for i , user := range p .PullRequest .Assignees {
175
171
list [i ] = linkFormatter (setting .AppURL + user .UserName , user .UserName )
176
172
}
177
- text = fmt .Sprintf ("[%s] Pull request assigned to %s: %s" , repoLink ,
173
+ text = fmt .Sprintf ("[%s] Pull request assigned to %s: %s" , p . Repository . FullName ,
178
174
strings .Join (list , ", " ), titleLink )
179
175
color = greenColor
180
176
case api .HookIssueUnassigned :
181
- text = fmt .Sprintf ("[%s] Pull request unassigned: %s" , repoLink , titleLink )
177
+ text = fmt .Sprintf ("[%s] Pull request unassigned: %s" , p . Repository . FullName , titleLink )
182
178
case api .HookIssueLabelUpdated :
183
- text = fmt .Sprintf ("[%s] Pull request labels updated: %s" , repoLink , titleLink )
179
+ text = fmt .Sprintf ("[%s] Pull request labels updated: %s" , p . Repository . FullName , titleLink )
184
180
case api .HookIssueLabelCleared :
185
- text = fmt .Sprintf ("[%s] Pull request labels cleared: %s" , repoLink , titleLink )
181
+ text = fmt .Sprintf ("[%s] Pull request labels cleared: %s" , p . Repository . FullName , titleLink )
186
182
case api .HookIssueSynchronized :
187
- text = fmt .Sprintf ("[%s] Pull request synchronized: %s" , repoLink , titleLink )
183
+ text = fmt .Sprintf ("[%s] Pull request synchronized: %s" , p . Repository . FullName , titleLink )
188
184
case api .HookIssueMilestoned :
189
- mileStoneLink := fmt .Sprintf ("%s/milestone/%d" , p .Repository .HTMLURL , p .PullRequest .Milestone .ID )
190
- text = fmt .Sprintf ("[%s] Pull request milestoned to %s: %s" , repoLink ,
191
- linkFormatter (mileStoneLink , p .PullRequest .Milestone .Title ), titleLink )
185
+ text = fmt .Sprintf ("[%s] Pull request milestoned to %s: %s" , p .Repository .FullName , p .PullRequest .Milestone .Title , titleLink )
192
186
case api .HookIssueDemilestoned :
193
- text = fmt .Sprintf ("[%s] Pull request milestone cleared: %s" , repoLink , titleLink )
187
+ text = fmt .Sprintf ("[%s] Pull request milestone cleared: %s" , p . Repository . FullName , titleLink )
194
188
case api .HookIssueReviewed :
195
- text = fmt .Sprintf ("[%s] Pull request reviewed: %s" , repoLink , titleLink )
189
+ text = fmt .Sprintf ("[%s] Pull request reviewed: %s" , p . Repository . FullName , titleLink )
196
190
attachmentText = p .Review .Content
197
191
case api .HookIssueReviewRequested :
198
- text = fmt .Sprintf ("[%s] Pull request review requested: %s" , repoLink , titleLink )
192
+ text = fmt .Sprintf ("[%s] Pull request review requested: %s" , p . Repository . FullName , titleLink )
199
193
case api .HookIssueReviewRequestRemoved :
200
- text = fmt .Sprintf ("[%s] Pull request review request removed: %s" , repoLink , titleLink )
194
+ text = fmt .Sprintf ("[%s] Pull request review request removed: %s" , p . Repository . FullName , titleLink )
201
195
}
202
196
if withSender {
203
- text += fmt .Sprintf (" by %s" , linkFormatter ( setting . AppURL + p .Sender .UserName , p . Sender . UserName ) )
197
+ text += fmt .Sprintf (" by %s" , p .Sender .UserName )
204
198
}
205
199
206
200
return text , issueTitle , attachmentText , color
207
201
}
208
202
209
203
func getReleasePayloadInfo (p * api.ReleasePayload , linkFormatter linkFormatter , withSender bool ) (text string , color int ) {
210
- repoLink := linkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
211
204
refLink := linkFormatter (p .Repository .HTMLURL + "/releases/tag/" + util .PathEscapeSegments (p .Release .TagName ), p .Release .TagName )
212
205
213
206
switch p .Action {
214
207
case api .HookReleasePublished :
215
- text = fmt .Sprintf ("[%s] Release created: %s" , repoLink , refLink )
208
+ text = fmt .Sprintf ("[%s] Release created: %s" , p . Repository . FullName , refLink )
216
209
color = greenColor
217
210
case api .HookReleaseUpdated :
218
- text = fmt .Sprintf ("[%s] Release updated: %s" , repoLink , refLink )
211
+ text = fmt .Sprintf ("[%s] Release updated: %s" , p . Repository . FullName , refLink )
219
212
color = yellowColor
220
213
case api .HookReleaseDeleted :
221
- text = fmt .Sprintf ("[%s] Release deleted: %s" , repoLink , refLink )
214
+ text = fmt .Sprintf ("[%s] Release deleted: %s" , p . Repository . FullName , refLink )
222
215
color = redColor
223
216
}
224
217
if withSender {
225
- text += fmt .Sprintf (" by %s" , linkFormatter ( setting . AppURL + url . PathEscape ( p .Sender .UserName ), p . Sender . UserName ) )
218
+ text += fmt .Sprintf (" by %s" , p .Sender .UserName )
226
219
}
227
220
228
221
return text , color
229
222
}
230
223
231
224
func getWikiPayloadInfo (p * api.WikiPayload , linkFormatter linkFormatter , withSender bool ) (string , int , string ) {
232
- repoLink := linkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
233
225
pageLink := linkFormatter (p .Repository .HTMLURL + "/wiki/" + url .PathEscape (p .Page ), p .Page )
234
226
235
227
var text string
236
228
color := greenColor
237
229
238
230
switch p .Action {
239
231
case api .HookWikiCreated :
240
- text = fmt .Sprintf ("[%s] New wiki page '%s'" , repoLink , pageLink )
232
+ text = fmt .Sprintf ("[%s] New wiki page '%s'" , p . Repository . FullName , pageLink )
241
233
case api .HookWikiEdited :
242
- text = fmt .Sprintf ("[%s] Wiki page '%s' edited" , repoLink , pageLink )
234
+ text = fmt .Sprintf ("[%s] Wiki page '%s' edited" , p . Repository . FullName , pageLink )
243
235
color = yellowColor
244
236
case api .HookWikiDeleted :
245
- text = fmt .Sprintf ("[%s] Wiki page '%s' deleted" , repoLink , pageLink )
237
+ text = fmt .Sprintf ("[%s] Wiki page '%s' deleted" , p . Repository . FullName , pageLink )
246
238
color = redColor
247
239
}
248
240
@@ -251,14 +243,13 @@ func getWikiPayloadInfo(p *api.WikiPayload, linkFormatter linkFormatter, withSen
251
243
}
252
244
253
245
if withSender {
254
- text += fmt .Sprintf (" by %s" , linkFormatter ( setting . AppURL + url . PathEscape ( p .Sender .UserName ), p . Sender . UserName ) )
246
+ text += fmt .Sprintf (" by %s" , p .Sender .UserName )
255
247
}
256
248
257
249
return text , color , pageLink
258
250
}
259
251
260
252
func getIssueCommentPayloadInfo (p * api.IssueCommentPayload , linkFormatter linkFormatter , withSender bool ) (string , string , int ) {
261
- repoLink := linkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
262
253
issueTitle := fmt .Sprintf ("#%d %s" , p .Issue .Index , p .Issue .Title )
263
254
264
255
var text , typ , titleLink string
@@ -274,20 +265,20 @@ func getIssueCommentPayloadInfo(p *api.IssueCommentPayload, linkFormatter linkFo
274
265
275
266
switch p .Action {
276
267
case api .HookIssueCommentCreated :
277
- text = fmt .Sprintf ("[%s] New comment on %s %s" , repoLink , typ , titleLink )
268
+ text = fmt .Sprintf ("[%s] New comment on %s %s" , p . Repository . FullName , typ , titleLink )
278
269
if p .IsPull {
279
270
color = greenColorLight
280
271
} else {
281
272
color = orangeColorLight
282
273
}
283
274
case api .HookIssueCommentEdited :
284
- text = fmt .Sprintf ("[%s] Comment edited on %s %s" , repoLink , typ , titleLink )
275
+ text = fmt .Sprintf ("[%s] Comment edited on %s %s" , p . Repository . FullName , typ , titleLink )
285
276
case api .HookIssueCommentDeleted :
286
- text = fmt .Sprintf ("[%s] Comment deleted on %s %s" , repoLink , typ , titleLink )
277
+ text = fmt .Sprintf ("[%s] Comment deleted on %s %s" , p . Repository . FullName , typ , titleLink )
287
278
color = redColor
288
279
}
289
280
if withSender {
290
- text += fmt .Sprintf (" by %s" , linkFormatter ( setting . AppURL + url . PathEscape ( p .Sender .UserName ), p . Sender . UserName ) )
281
+ text += fmt .Sprintf (" by %s" , p .Sender .UserName )
291
282
}
292
283
293
284
return text , issueTitle , color
@@ -305,7 +296,7 @@ func getPackagePayloadInfo(p *api.PackagePayload, linkFormatter linkFormatter, w
305
296
color = redColor
306
297
}
307
298
if withSender {
308
- text += fmt .Sprintf (" by %s" , linkFormatter ( setting . AppURL + url . PathEscape ( p .Sender .UserName ), p . Sender . UserName ) )
299
+ text += fmt .Sprintf (" by %s" , p .Sender .UserName )
309
300
}
310
301
311
302
return text , color
0 commit comments