@@ -18,7 +18,7 @@ class CIPullRequestHook extends PullRequestHook
18
18
with WebHookPullRequestService with WebHookPullRequestReviewCommentService with ActivityService with MergeService
19
19
with RepositoryService with LabelsService with PrioritiesService with MilestonesService with CIService {
20
20
21
- override def created (issue : Issue , repository : RepositoryInfo )(implicit session : Session , context : Context ): Unit = {
21
+ private def runBuildWith (issue : Issue , repository : RepositoryInfo , isMergeRequest : Boolean )(implicit session : Session , context : Context ): Unit = {
22
22
if (issue.isPullRequest){
23
23
for {
24
24
(_, pullreq) <- getPullRequest(issue.userName, issue.repositoryName, issue.issueId)
@@ -34,8 +34,17 @@ class CIPullRequestHook extends PullRequestHook
34
34
repositoryName = pullreq.repositoryName,
35
35
buildUserName = pullreq.requestUserName,
36
36
buildRepositoryName = pullreq.requestRepositoryName,
37
- buildBranch = pullreq.requestBranch,
38
- sha = pullreq.commitIdTo,
37
+ buildBranch = isMergeRequest match {
38
+ case true => pullreq.branch
39
+ case false => pullreq.requestBranch
40
+ },
41
+ sha = isMergeRequest match {
42
+ case true => Using .resource(Git .open(getRepositoryDir(pullreq.userName, pullreq.repositoryName))) { git =>
43
+ val objectId = git.getRepository.resolve(pullreq.branch)
44
+ objectId.name
45
+ }
46
+ case false => pullreq.commitIdTo
47
+ },
39
48
commitMessage = revCommit.getShortMessage,
40
49
commitUserName = revCommit.getCommitterIdent.getName,
41
50
commitMailAddress = revCommit.getCommitterIdent.getEmailAddress,
@@ -47,6 +56,13 @@ class CIPullRequestHook extends PullRequestHook
47
56
}
48
57
}
49
58
59
+ override def created (issue : Issue , repository : RepositoryInfo )(implicit session : Session , context : Context ): Unit =
60
+ runBuildWith(issue, repository, false )
61
+
62
+ override def merged (issue : Issue , repository : RepositoryInfo )(implicit session : Session , context : Context ): Unit =
63
+ runBuildWith(issue, repository, true )
64
+
65
+
50
66
override def addedComment (commentId : Int , content : String , issue : Issue , repository : RepositoryInfo )
51
67
(implicit session : Session , context : Context ): Unit = {
52
68
if (issue.isPullRequest){
@@ -79,5 +95,4 @@ class CIPullRequestHook extends PullRequestHook
79
95
}
80
96
}
81
97
82
-
83
98
}
0 commit comments