-
Notifications
You must be signed in to change notification settings - Fork 384
[JENKINS-57371] - Enable graceful fallback for merge hash #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e6d4cda to
0ae74a0
Compare
| if (pr.getMergeable() != null) { | ||
| mergeHash = Boolean.TRUE.equals(pr.getMergeable()) ? pr.getMergeCommitSha() : PullRequestSCMRevision.NOT_MERGEABLE_HASH; | ||
|
|
||
| if (prhead.isMerge()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we would validate the merge later. Now we do a bunch of work to make the merge valid or to ignore it.
| if (parents.size() != 2 || !parents.contains(this.getBaseHash()) || !parents.contains(this.getPullHash())) { | ||
| throw new AbortException("Invalid merge hash for pull request " + ((PullRequestSCMHead)this.getHead()).getNumber() + " : Head and base commits do match merge commit " + this.toString() ); | ||
| } | ||
| void validateMergeHash() throws AbortException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted, this validation used to be called in several places and be super strict. Now the checks are done at create time and additional work is done then to make the merge hash valid or to make it null (which case the FileSource will fall back to clone and merge locally).
src/test/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevisionTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevisionTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good so far
We tried using strict merge commit handling to prevent cloning on master. This resulted in some edge cases for some users where PRs would simply not build and there was not viable workaround. Change: * Merge hash has been changed to best effort. If it is missing or inconsistent, Jenkins will gracefully revert to cloning on master. * Most validity checking for merge hash has been moved to create time. * Plugin tries harder than before to create a valid merge hash revision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Side note, I really like the practice of putting comments into your own PRs explaining what's going on. That is really helpful.
Though most of the time I'm wondering why those comments aren't in the code instead. |
We tried using strict merge commit handling to prevent cloning on master.
This resulted in some edge cases for some users where PRs would simply not build
and there was not viable workaround.
Change:
Jenkins will gracefully revert to cloning on master.
https://issues.jenkins-ci.org/browse/JENKINS-57371