@@ -104,7 +104,7 @@ func SlackLinkToRef(repoURL, ref string) string {
104
104
}
105
105
106
106
func getSlackCreatePayload (p * api.CreatePayload , slack * SlackMeta ) (* SlackPayload , error ) {
107
- repoLink := SlackLinkFormatter (p .Repo .HTMLURL , p .Repo .Name )
107
+ repoLink := SlackLinkFormatter (p .Repo .HTMLURL , p .Repo .FullName )
108
108
refLink := SlackLinkToRef (p .Repo .HTMLURL , p .Ref )
109
109
text := fmt .Sprintf ("[%s:%s] %s created by %s" , repoLink , refLink , p .RefType , p .Sender .UserName )
110
110
@@ -119,7 +119,7 @@ func getSlackCreatePayload(p *api.CreatePayload, slack *SlackMeta) (*SlackPayloa
119
119
// getSlackDeletePayload composes Slack payload for delete a branch or tag.
120
120
func getSlackDeletePayload (p * api.DeletePayload , slack * SlackMeta ) (* SlackPayload , error ) {
121
121
refName := git .RefEndName (p .Ref )
122
- repoLink := SlackLinkFormatter (p .Repo .HTMLURL , p .Repo .Name )
122
+ repoLink := SlackLinkFormatter (p .Repo .HTMLURL , p .Repo .FullName )
123
123
text := fmt .Sprintf ("[%s:%s] %s deleted by %s" , repoLink , refName , p .RefType , p .Sender .UserName )
124
124
return & SlackPayload {
125
125
Channel : slack .Channel ,
@@ -146,35 +146,36 @@ func getSlackIssuesPayload(p *api.IssuePayload, slack *SlackMeta) (*SlackPayload
146
146
senderLink := SlackLinkFormatter (setting .AppURL + p .Sender .UserName , p .Sender .UserName )
147
147
titleLink := SlackLinkFormatter (fmt .Sprintf ("%s/pulls/%d" , p .Repository .HTMLURL , p .Index ),
148
148
fmt .Sprintf ("#%d %s" , p .Index , p .Issue .Title ))
149
+ repoLink := SlackLinkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
149
150
var text , title , attachmentText string
150
151
switch p .Action {
151
152
case api .HookIssueOpened :
152
- text = fmt .Sprintf ("[%s] Issue submitted by %s" , p . Repository . FullName , senderLink )
153
+ text = fmt .Sprintf ("[%s] Issue submitted by %s" , repoLink , senderLink )
153
154
title = titleLink
154
155
attachmentText = SlackTextFormatter (p .Issue .Body )
155
156
case api .HookIssueClosed :
156
- text = fmt .Sprintf ("[%s] Issue closed: %s by %s" , p . Repository . FullName , titleLink , senderLink )
157
+ text = fmt .Sprintf ("[%s] Issue closed: %s by %s" , repoLink , titleLink , senderLink )
157
158
case api .HookIssueReOpened :
158
- text = fmt .Sprintf ("[%s] Issue re-opened: %s by %s" , p . Repository . FullName , titleLink , senderLink )
159
+ text = fmt .Sprintf ("[%s] Issue re-opened: %s by %s" , repoLink , titleLink , senderLink )
159
160
case api .HookIssueEdited :
160
- text = fmt .Sprintf ("[%s] Issue edited: %s by %s" , p . Repository . FullName , titleLink , senderLink )
161
+ text = fmt .Sprintf ("[%s] Issue edited: %s by %s" , repoLink , titleLink , senderLink )
161
162
attachmentText = SlackTextFormatter (p .Issue .Body )
162
163
case api .HookIssueAssigned :
163
- text = fmt .Sprintf ("[%s] Issue assigned to %s: %s by %s" , p . Repository . FullName ,
164
+ text = fmt .Sprintf ("[%s] Issue assigned to %s: %s by %s" , repoLink ,
164
165
SlackLinkFormatter (setting .AppURL + p .Issue .Assignee .UserName , p .Issue .Assignee .UserName ),
165
166
titleLink , senderLink )
166
167
case api .HookIssueUnassigned :
167
- text = fmt .Sprintf ("[%s] Issue unassigned: %s by %s" , p . Repository . FullName , titleLink , senderLink )
168
+ text = fmt .Sprintf ("[%s] Issue unassigned: %s by %s" , repoLink , titleLink , senderLink )
168
169
case api .HookIssueLabelUpdated :
169
- text = fmt .Sprintf ("[%s] Issue labels updated: %s by %s" , p . Repository . FullName , titleLink , senderLink )
170
+ text = fmt .Sprintf ("[%s] Issue labels updated: %s by %s" , repoLink , titleLink , senderLink )
170
171
case api .HookIssueLabelCleared :
171
- text = fmt .Sprintf ("[%s] Issue labels cleared: %s by %s" , p . Repository . FullName , titleLink , senderLink )
172
+ text = fmt .Sprintf ("[%s] Issue labels cleared: %s by %s" , repoLink , titleLink , senderLink )
172
173
case api .HookIssueSynchronized :
173
- text = fmt .Sprintf ("[%s] Issue synchronized: %s by %s" , p . Repository . FullName , titleLink , senderLink )
174
+ text = fmt .Sprintf ("[%s] Issue synchronized: %s by %s" , repoLink , titleLink , senderLink )
174
175
case api .HookIssueMilestoned :
175
- text = fmt .Sprintf ("[%s] Issue milestoned: #%s %s" , p . Repository . FullName , titleLink , senderLink )
176
+ text = fmt .Sprintf ("[%s] Issue milestoned: #%s %s" , repoLink , titleLink , senderLink )
176
177
case api .HookIssueDemilestoned :
177
- text = fmt .Sprintf ("[%s] Issue milestone cleared: #%s %s" , p . Repository . FullName , titleLink , senderLink )
178
+ text = fmt .Sprintf ("[%s] Issue milestone cleared: #%s %s" , repoLink , titleLink , senderLink )
178
179
}
179
180
180
181
return & SlackPayload {
@@ -194,18 +195,19 @@ func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (
194
195
senderLink := SlackLinkFormatter (setting .AppURL + p .Sender .UserName , p .Sender .UserName )
195
196
titleLink := SlackLinkFormatter (fmt .Sprintf ("%s/issues/%d#%s" , p .Repository .HTMLURL , p .Issue .Index , models .CommentHashTag (p .Comment .ID )),
196
197
fmt .Sprintf ("#%d %s" , p .Issue .Index , p .Issue .Title ))
198
+ repoLink := SlackLinkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
197
199
var text , title , attachmentText string
198
200
switch p .Action {
199
201
case api .HookIssueCommentCreated :
200
- text = fmt .Sprintf ("[%s] New comment created by %s" , p . Repository . FullName , senderLink )
202
+ text = fmt .Sprintf ("[%s] New comment created by %s" , repoLink , senderLink )
201
203
title = titleLink
202
204
attachmentText = SlackTextFormatter (p .Comment .Body )
203
205
case api .HookIssueCommentEdited :
204
- text = fmt .Sprintf ("[%s] Comment edited by %s" , p . Repository . FullName , senderLink )
206
+ text = fmt .Sprintf ("[%s] Comment edited by %s" , repoLink , senderLink )
205
207
title = titleLink
206
208
attachmentText = SlackTextFormatter (p .Comment .Body )
207
209
case api .HookIssueCommentDeleted :
208
- text = fmt .Sprintf ("[%s] Comment deleted by %s" , p . Repository . FullName , senderLink )
210
+ text = fmt .Sprintf ("[%s] Comment deleted by %s" , repoLink , senderLink )
209
211
title = SlackLinkFormatter (fmt .Sprintf ("%s/issues/%d" , p .Repository .HTMLURL , p .Issue .Index ),
210
212
fmt .Sprintf ("#%d %s" , p .Issue .Index , p .Issue .Title ))
211
213
attachmentText = SlackTextFormatter (p .Comment .Body )
@@ -225,7 +227,7 @@ func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (
225
227
}
226
228
227
229
func getSlackReleasePayload (p * api.ReleasePayload , slack * SlackMeta ) (* SlackPayload , error ) {
228
- repoLink := SlackLinkFormatter (p .Repository .HTMLURL , p .Repository .Name )
230
+ repoLink := SlackLinkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
229
231
refLink := SlackLinkFormatter (p .Repository .HTMLURL + "/src/" + p .Release .TagName , p .Release .TagName )
230
232
var text string
231
233
@@ -264,7 +266,7 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e
264
266
commitString = commitDesc
265
267
}
266
268
267
- repoLink := SlackLinkFormatter (p .Repo .HTMLURL , p .Repo .Name )
269
+ repoLink := SlackLinkFormatter (p .Repo .HTMLURL , p .Repo .FullName )
268
270
branchLink := SlackLinkToRef (p .Repo .HTMLURL , p .Ref )
269
271
text := fmt .Sprintf ("[%s:%s] %s pushed by %s" , repoLink , branchLink , commitString , p .Pusher .UserName )
270
272
@@ -294,43 +296,44 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S
294
296
senderLink := SlackLinkFormatter (setting .AppURL + p .Sender .UserName , p .Sender .UserName )
295
297
titleLink := SlackLinkFormatter (fmt .Sprintf ("%s/pulls/%d" , p .Repository .HTMLURL , p .Index ),
296
298
fmt .Sprintf ("#%d %s" , p .Index , p .PullRequest .Title ))
299
+ repoLink := SlackLinkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
297
300
var text , title , attachmentText string
298
301
switch p .Action {
299
302
case api .HookIssueOpened :
300
- text = fmt .Sprintf ("[%s] Pull request submitted by %s" , p . Repository . FullName , senderLink )
303
+ text = fmt .Sprintf ("[%s] Pull request submitted by %s" , repoLink , senderLink )
301
304
title = titleLink
302
305
attachmentText = SlackTextFormatter (p .PullRequest .Body )
303
306
case api .HookIssueClosed :
304
307
if p .PullRequest .HasMerged {
305
- text = fmt .Sprintf ("[%s] Pull request merged: %s by %s" , p . Repository . FullName , titleLink , senderLink )
308
+ text = fmt .Sprintf ("[%s] Pull request merged: %s by %s" , repoLink , titleLink , senderLink )
306
309
} else {
307
- text = fmt .Sprintf ("[%s] Pull request closed: %s by %s" , p . Repository . FullName , titleLink , senderLink )
310
+ text = fmt .Sprintf ("[%s] Pull request closed: %s by %s" , repoLink , titleLink , senderLink )
308
311
}
309
312
case api .HookIssueReOpened :
310
- text = fmt .Sprintf ("[%s] Pull request re-opened: %s by %s" , p . Repository . FullName , titleLink , senderLink )
313
+ text = fmt .Sprintf ("[%s] Pull request re-opened: %s by %s" , repoLink , titleLink , senderLink )
311
314
case api .HookIssueEdited :
312
- text = fmt .Sprintf ("[%s] Pull request edited: %s by %s" , p . Repository . FullName , titleLink , senderLink )
315
+ text = fmt .Sprintf ("[%s] Pull request edited: %s by %s" , repoLink , titleLink , senderLink )
313
316
attachmentText = SlackTextFormatter (p .PullRequest .Body )
314
317
case api .HookIssueAssigned :
315
318
list := make ([]string , len (p .PullRequest .Assignees ))
316
319
for i , user := range p .PullRequest .Assignees {
317
320
list [i ] = SlackLinkFormatter (setting .AppURL + user .UserName , user .UserName )
318
321
}
319
- text = fmt .Sprintf ("[%s] Pull request assigned to %s: %s by %s" , p . Repository . FullName ,
322
+ text = fmt .Sprintf ("[%s] Pull request assigned to %s: %s by %s" , repoLink ,
320
323
strings .Join (list , ", " ),
321
324
titleLink , senderLink )
322
325
case api .HookIssueUnassigned :
323
- text = fmt .Sprintf ("[%s] Pull request unassigned: %s by %s" , p . Repository . FullName , titleLink , senderLink )
326
+ text = fmt .Sprintf ("[%s] Pull request unassigned: %s by %s" , repoLink , titleLink , senderLink )
324
327
case api .HookIssueLabelUpdated :
325
- text = fmt .Sprintf ("[%s] Pull request labels updated: %s by %s" , p . Repository . FullName , titleLink , senderLink )
328
+ text = fmt .Sprintf ("[%s] Pull request labels updated: %s by %s" , repoLink , titleLink , senderLink )
326
329
case api .HookIssueLabelCleared :
327
- text = fmt .Sprintf ("[%s] Pull request labels cleared: %s by %s" , p . Repository . FullName , titleLink , senderLink )
330
+ text = fmt .Sprintf ("[%s] Pull request labels cleared: %s by %s" , repoLink , titleLink , senderLink )
328
331
case api .HookIssueSynchronized :
329
- text = fmt .Sprintf ("[%s] Pull request synchronized: %s by %s" , p . Repository . FullName , titleLink , senderLink )
332
+ text = fmt .Sprintf ("[%s] Pull request synchronized: %s by %s" , repoLink , titleLink , senderLink )
330
333
case api .HookIssueMilestoned :
331
- text = fmt .Sprintf ("[%s] Pull request milestoned: #%s %s" , p . Repository . FullName , titleLink , senderLink )
334
+ text = fmt .Sprintf ("[%s] Pull request milestoned: #%s %s" , repoLink , titleLink , senderLink )
332
335
case api .HookIssueDemilestoned :
333
- text = fmt .Sprintf ("[%s] Pull request milestone cleared: #%s %s" , p . Repository . FullName , titleLink , senderLink )
336
+ text = fmt .Sprintf ("[%s] Pull request milestone cleared: #%s %s" , repoLink , titleLink , senderLink )
334
337
}
335
338
336
339
return & SlackPayload {
@@ -350,6 +353,7 @@ func getSlackPullRequestApprovalPayload(p *api.PullRequestPayload, slack *SlackM
350
353
senderLink := SlackLinkFormatter (setting .AppURL + p .Sender .UserName , p .Sender .UserName )
351
354
titleLink := SlackLinkFormatter (fmt .Sprintf ("%s/pulls/%d" , p .Repository .HTMLURL , p .Index ),
352
355
fmt .Sprintf ("#%d %s" , p .Index , p .PullRequest .Title ))
356
+ repoLink := SlackLinkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
353
357
var text , title , attachmentText string
354
358
switch p .Action {
355
359
case api .HookIssueSynchronized :
@@ -358,7 +362,7 @@ func getSlackPullRequestApprovalPayload(p *api.PullRequestPayload, slack *SlackM
358
362
return nil , err
359
363
}
360
364
361
- text = fmt .Sprintf ("[%s] Pull request review %s : %s by %s" , p . Repository . FullName , action , titleLink , senderLink )
365
+ text = fmt .Sprintf ("[%s] Pull request review %s : %s by %s" , repoLink , action , titleLink , senderLink )
362
366
}
363
367
364
368
return & SlackPayload {
@@ -376,13 +380,14 @@ func getSlackPullRequestApprovalPayload(p *api.PullRequestPayload, slack *SlackM
376
380
377
381
func getSlackRepositoryPayload (p * api.RepositoryPayload , slack * SlackMeta ) (* SlackPayload , error ) {
378
382
senderLink := SlackLinkFormatter (setting .AppURL + p .Sender .UserName , p .Sender .UserName )
383
+ repoLink := SlackLinkFormatter (p .Repository .HTMLURL , p .Repository .FullName )
379
384
var text , title , attachmentText string
380
385
switch p .Action {
381
386
case api .HookRepoCreated :
382
- text = fmt .Sprintf ("[%s] Repository created by %s" , p . Repository . FullName , senderLink )
387
+ text = fmt .Sprintf ("[%s] Repository created by %s" , repoLink , senderLink )
383
388
title = p .Repository .HTMLURL
384
389
case api .HookRepoDeleted :
385
- text = fmt .Sprintf ("[%s] Repository deleted by %s" , p . Repository . FullName , senderLink )
390
+ text = fmt .Sprintf ("[%s] Repository deleted by %s" , repoLink , senderLink )
386
391
}
387
392
388
393
return & SlackPayload {
0 commit comments