@@ -66,12 +66,19 @@ type UserInfoModel struct {
6666
6767// RepositoryInfoModel ...
6868type RepositoryInfoModel struct {
69- Slug string `json:"slug"`
70- ID int `json:"id"`
71- Name string `json:"name"`
72- Public bool `json:"public"`
73- Scm string `json:"scmId"`
74- Project ProjectInfoModel `json:"project"`
69+ Slug string `json:"slug"`
70+ ID int `json:"id"`
71+ Name string `json:"name"`
72+ Public bool `json:"public"`
73+ Scm string `json:"scmId"`
74+ Project ProjectInfoModel `json:"project"`
75+ Links map [string ][]LinkModel `json:"links"`
76+ }
77+
78+ // LinkModel ...
79+ type LinkModel struct {
80+ Name string `json:"name"`
81+ Href string `json:"href"`
7582}
7683
7784// CommitModel ...
@@ -216,10 +223,11 @@ func transformPushEvent(pushEvent PushEventModel) hookCommon.TransformResultMode
216223
217224 aTriggerAPIParams := bitriseapi.TriggerAPIParamsModel {
218225 BuildParams : bitriseapi.BuildParamsModel {
219- Branch : aChange .Ref .DisplayID ,
220- CommitHash : aChange .ToHash ,
221- CommitMessage : headCommmitMessage ,
222- CommitMessages : allCommitMessages ,
226+ Branch : aChange .Ref .DisplayID ,
227+ CommitHash : aChange .ToHash ,
228+ CommitMessage : headCommmitMessage ,
229+ CommitMessages : allCommitMessages ,
230+ BaseRepositoryURL : pushEvent .RepositoryInfo .getRepositoryURL (),
223231 },
224232 TriggeredBy : hookCommon .GenerateTriggeredBy (ProviderID , pushEvent .Actor .Name ),
225233 }
@@ -234,10 +242,11 @@ func transformPushEvent(pushEvent PushEventModel) hookCommon.TransformResultMode
234242
235243 aTriggerAPIParams := bitriseapi.TriggerAPIParamsModel {
236244 BuildParams : bitriseapi.BuildParamsModel {
237- Tag : aChange .Ref .DisplayID ,
238- CommitHash : aChange .ToHash ,
239- CommitMessage : headCommmitMessage ,
240- CommitMessages : allCommitMessages ,
245+ Tag : aChange .Ref .DisplayID ,
246+ CommitHash : aChange .ToHash ,
247+ CommitMessage : headCommmitMessage ,
248+ CommitMessages : allCommitMessages ,
249+ BaseRepositoryURL : pushEvent .RepositoryInfo .getRepositoryURL (),
241250 },
242251 TriggeredBy : hookCommon .GenerateTriggeredBy (ProviderID , pushEvent .Actor .Name ),
243252 }
@@ -279,23 +288,42 @@ func transformPullRequestEvent(pullRequest PullRequestEventModel) hookCommon.Tra
279288 TriggerAPIParams : []bitriseapi.TriggerAPIParamsModel {
280289 {
281290 BuildParams : bitriseapi.BuildParamsModel {
282- CommitMessage : commitMsg ,
283- CommitHash : pullRequest .PullRequest .FromRef .LatestCommit ,
284- Branch : pullRequest .PullRequest .FromRef .DisplayID ,
285- BranchRepoOwner : pullRequest .PullRequest .FromRef .Repository .Project .Key ,
286- BranchDest : pullRequest .PullRequest .ToRef .DisplayID ,
287- BranchDestRepoOwner : pullRequest .PullRequest .ToRef .Repository .Project .Key ,
288- PullRequestID : & pullRequest .PullRequest .ID ,
289- PullRequestAuthor : pullRequest .PullRequest .Author .User .Name ,
290- PullRequestComment : comment ,
291- PullRequestCommentID : commentID ,
291+ CommitMessage : commitMsg ,
292+ CommitHash : pullRequest .PullRequest .FromRef .LatestCommit ,
293+ Branch : pullRequest .PullRequest .FromRef .DisplayID ,
294+ BranchRepoOwner : pullRequest .PullRequest .FromRef .Repository .Project .Key ,
295+ BranchDest : pullRequest .PullRequest .ToRef .DisplayID ,
296+ BranchDestRepoOwner : pullRequest .PullRequest .ToRef .Repository .Project .Key ,
297+ PullRequestID : & pullRequest .PullRequest .ID ,
298+ BaseRepositoryURL : pullRequest .PullRequest .ToRef .Repository .getRepositoryURL (),
299+ HeadRepositoryURL : pullRequest .PullRequest .FromRef .Repository .getRepositoryURL (),
300+ PullRequestRepositoryURL : pullRequest .PullRequest .FromRef .Repository .getRepositoryURL (),
301+ PullRequestAuthor : pullRequest .PullRequest .Author .User .Name ,
302+ PullRequestComment : comment ,
303+ PullRequestCommentID : commentID ,
292304 },
293305 TriggeredBy : hookCommon .GenerateTriggeredBy (ProviderID , pullRequest .Actor .Name ),
294306 },
295307 },
296308 }
297309}
298310
311+ func (repository RepositoryInfoModel ) getRepositoryURL () string {
312+ if cloneLinks , ok := repository .Links ["clone" ]; ok {
313+ for _ , link := range cloneLinks {
314+ if link .Name == "ssh" && ! repository .Public {
315+ return link .Href
316+ }
317+
318+ if link .Name == "http" && repository .Public {
319+ return link .Href
320+ }
321+ }
322+ }
323+
324+ return ""
325+ }
326+
299327func isAcceptEventType (eventKey string ) bool {
300328 return slices .Contains ([]string {"repo:refs_changed" , "pr:opened" , "pr:modified" , "pr:merged" , "diagnostics:ping" , "pr:from_ref_updated" , "pr:comment:added" , "pr:comment:edited" }, eventKey )
301329}
0 commit comments