You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Merge commits always merge against the most recent base commit they can detect.
1565
+
if (parents.size() != 2) {
1566
+
listener.getLogger().format("WARNING: Invalid github merge_commit_sha for pull request %s : merge commit %s with parents - %s.%n",
1567
+
pr.getNumber(),
1568
+
proposedMergeHash,
1569
+
StringUtils.join(parents, "+"));
1570
+
} elseif (!parents.contains(prHeadHash)) {
1571
+
// This is maintains the existing behavior from pre-2.5.x when the merge_commit_sha is out of sync from the requested prHead
1572
+
listener.getLogger().format("WARNING: Invalid github merge_commit_sha for pull request %s : Head commit %s does match merge commit %s with parents - %s.%n",
1573
+
pr.getNumber(),
1574
+
prHeadHash,
1575
+
proposedMergeHash,
1576
+
StringUtils.join(parents, "+"));
1577
+
} else {
1578
+
// We found a merge_commit_sha with 2 parents and one matches the prHeadHash
1579
+
// Use the other parent hash as the base. This keeps the merge hash in sync with head and base.
1580
+
// It is possible that head or base hash will not exist in their branch by the time we build
1581
+
// This is be true (and cause a failure) regardless of how we determine the commits.
thrownewAbortException("Invalid merge hash for pull request " + ((PullRequestSCMHead)this.getHead()).getNumber() + " : Not a merge head");
112
-
} elseif (this.mergeHash == null) {
113
-
thrownewAbortException("Invalid merge hash for pull request " + ((PullRequestSCMHead)this.getHead()).getNumber() + " : Unknown merge state " + this.toString());
114
-
} elseif (this.mergeHash == NOT_MERGEABLE_HASH) {
115
-
thrownewAbortException("Invalid merge hash for pull request " + ((PullRequestSCMHead)this.getHead()).getNumber() + " : Not mergeable " + this.toString());
116
-
} else {
117
-
GHCommitcommit = null;
118
-
try {
119
-
commit = repo.getCommit(this.mergeHash);
120
-
} catch (FileNotFoundExceptione) {
121
-
thrownewAbortException("Invalid merge hash for pull request " + ((PullRequestSCMHead)this.getHead()).getNumber() + " : commit not found (" + this.mergeHash + "). Close and reopen the PR to reset its merge hash.");
if (parents.size() != 2 || !parents.contains(this.getBaseHash()) || !parents.contains(this.getPullHash())) {
128
-
thrownewAbortException("Invalid merge hash for pull request " + ((PullRequestSCMHead)this.getHead()).getNumber() + " : Head and base commits do match merge commit " + this.toString() );
129
-
}
109
+
voidvalidateMergeHash() throwsAbortException {
110
+
if (this.mergeHash == NOT_MERGEABLE_HASH) {
111
+
thrownewAbortException("Pull request " + ((PullRequestSCMHead)this.getHead()).getNumber() + " : Not mergeable at " + this.toString());
0 commit comments