@@ -66,19 +66,12 @@ 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"`
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"`
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"`
8275}
8376
8477// CommitModel ...
@@ -223,11 +216,10 @@ func transformPushEvent(pushEvent PushEventModel) hookCommon.TransformResultMode
223216
224217 aTriggerAPIParams := bitriseapi.TriggerAPIParamsModel {
225218 BuildParams : bitriseapi.BuildParamsModel {
226- Branch : aChange .Ref .DisplayID ,
227- CommitHash : aChange .ToHash ,
228- CommitMessage : headCommmitMessage ,
229- CommitMessages : allCommitMessages ,
230- BaseRepositoryURL : pushEvent .RepositoryInfo .getRepositoryURL (),
219+ Branch : aChange .Ref .DisplayID ,
220+ CommitHash : aChange .ToHash ,
221+ CommitMessage : headCommmitMessage ,
222+ CommitMessages : allCommitMessages ,
231223 },
232224 TriggeredBy : hookCommon .GenerateTriggeredBy (ProviderID , pushEvent .Actor .Name ),
233225 }
@@ -242,11 +234,10 @@ func transformPushEvent(pushEvent PushEventModel) hookCommon.TransformResultMode
242234
243235 aTriggerAPIParams := bitriseapi.TriggerAPIParamsModel {
244236 BuildParams : bitriseapi.BuildParamsModel {
245- Tag : aChange .Ref .DisplayID ,
246- CommitHash : aChange .ToHash ,
247- CommitMessage : headCommmitMessage ,
248- CommitMessages : allCommitMessages ,
249- BaseRepositoryURL : pushEvent .RepositoryInfo .getRepositoryURL (),
237+ Tag : aChange .Ref .DisplayID ,
238+ CommitHash : aChange .ToHash ,
239+ CommitMessage : headCommmitMessage ,
240+ CommitMessages : allCommitMessages ,
250241 },
251242 TriggeredBy : hookCommon .GenerateTriggeredBy (ProviderID , pushEvent .Actor .Name ),
252243 }
@@ -288,42 +279,23 @@ func transformPullRequestEvent(pullRequest PullRequestEventModel) hookCommon.Tra
288279 TriggerAPIParams : []bitriseapi.TriggerAPIParamsModel {
289280 {
290281 BuildParams : bitriseapi.BuildParamsModel {
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 ,
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 ,
304292 },
305293 TriggeredBy : hookCommon .GenerateTriggeredBy (ProviderID , pullRequest .Actor .Name ),
306294 },
307295 },
308296 }
309297}
310298
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-
327299func isAcceptEventType (eventKey string ) bool {
328300 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 )
329301}
0 commit comments