File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,6 +90,21 @@ node('linux') {
9090 sh ' git rev-parse HEAD > tmp/GIT_COMMIT'
9191 git_branch = readFile(' tmp/GIT_BRANCH' ). trim()
9292 git_commit = readFile(' tmp/GIT_COMMIT' ). trim()
93+
94+ if (git_branch != " remotes/origin/master" ) {
95+ // Determine actual PR commit, if necessary
96+ sh ' git rev-parse HEAD | git log --pretty=%P -n 1 --date-order > tmp/MERGE_COMMIT_PARENTS'
97+ sh ' cat tmp/MERGE_COMMIT_PARENTS'
98+ merge_commit_parents = readFile(' tmp/MERGE_COMMIT_PARENTS' ). trim()
99+ if (merge_commit_parents. length() > 40 ) {
100+ echo ' More than one merge commit parent signifies that the merge commit is not the PR commit'
101+ echo " Changing git_commit from '${ git_commit} ' to '${ merge_commit_parents.take(40)} '"
102+ git_commit = merge_commit_parents. take(40 )
103+ } else {
104+ echo ' Only one merge commit parent signifies that the merge commit is also the PR commit'
105+ echo " Keeping git_commit as '${ git_commit} '"
106+ }
107+ }
93108 }
94109}
95110
You can’t perform that action at this time.
0 commit comments