(WIP) [JENKINS-20389] Merge commits trigger uneccessary builds when Include/Exclude regions are defined#162
Conversation
similar to git diff --name-only, so that it can be used to accurately identify changed paths for include/exclude regions.
|
Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests |
|
When can I expect this change to be merged and available as updates? |
|
It can be as much as several months before a git client plugin change proposal is merged and released, particularly one that changes a fundamental technique like this one does. If you want to run it sooner, you can fork a copy of the git client plugin repo, pull this change into it, and deploy it in your environment. |
similar to git diff --name-only, so that it can be used to accurately identify changed paths for include/exclude regions.
JGit does not support Octopus merge
JGit does not seem to have an implementation of an octopus merge, so the test falls back to performing the octopus merge with command line git.
Tests used to show places where the behavior is different between command line git and JGit implementation of showChangedPaths, and where the results are unexpected for both implementations.
The showChangedPaths() method for CliGitAPIImpl returns duplicates in the list, while the JGit implementation only returns the matching items
One case where the method is not consistent is documented inside the assertion.
Rename to match the wider use
Use assertion more widely
|
I've evaluated this pull request and provided a test which shows several areas where the JGit and command line git behaviors are different, and where the new API behaves unexpectedly. Please refer to [https://github.com/MarkEWaite/git-client-plugin/commit/19874b752bf01149ba8e57b4926e929ada1d4c13] for the test source code. Can you resolve those issues and the pull request can be evaluated again? |
fc708cf to
886a322
Compare
|
Any news with this pull request? Do you have an ETA? |
|
@pabloa Until the author of the pull request resolves the issues where the new API behaves differently between JGit and command line git, and until the author of the pull request resolves the places where the API behaves unexpectedly, this pull request won't be merged. If you'd like to speed that process, you're welcome to resolve those issues and make those consistency changes. I felt that I already went far beyond the required by spending the time to write tests and use those tests to show issues with the proposed API. Have you evaluated the pull request and found that it meets your needs? If so, can you describe those needs so that I understand better and can consider if I need to be the one to fix the problems in the proposed pull request (at the expense of other bug fixes and helping users). |
…/merge-commits-include-regions
* Fix cli empty and duplicate responses * Fix jGit diff to use merge base for the start commit
|
I would like to apologize to everyone here for my extreme delay in responding. It was not my intent to abandon this pull request after creating it. @MarkEWaite I've fixed some, but not all, of the inconsistencies you've pointed out. What's fixed:
JGit:
What's not fixed:
Also, I'm using mergeBase() but it's marked as deprecated, should I just remove the |
|
@aelsabbahy Do you know why this was never merged? |
|
I think it was the octopus merge case. I couldn't figure out how to do it in JGit, not sure how the owner would like to proceed. |
|
Any update with this pull request? |
|
I have probably triggered probably issue JENKINS-38722 which this pull request solves. Imho semantically is git diff better for given purpose than git log. I would like to build job, when there is difference from last build and not if there were some changes, which were than removed and made thus "invisible" to building project. It would break only projects which somehow uses git history in build (for example adding changelogs or so). From my point of view it would be best if user can choose what change in repository means. If any change (also invisible ones) or change in actual codebase from last build (i.e. diff). |
|
I tried out this PR merging (resoving some trivial conflicts) this pull request in git-client-2.1.0 and using the patched plugin version. Alas, the problem is still there... |
|
In Git polling log I see that still git-log is used. Is there anything to activate in the plugin for the new approach (git-diff) to take place? |
|
I'm also affected with this issue. So +1 from me to speed up the fix |
|
@neizmirasego, you're encouraged to checkout your own copy of the plugin and evaluate the pull request in your use case. @antonsmyk did that and found that it did not resolve his issue. I am unlikely to work on this pull request for at least several months so that I can work on authentication related issues and submodule related issues which I believe are higher priority. |
|
Hello to everyone and thanks for handling requests from large audience! I also have the same issue ( a merge will trigger build even if "Included Regions" doesn't contain the "touched path" ). This is very painful for me as I just moved from SVN to GitHub and it use to work in SVN. I need to make it work somehow in Git too. |
|
@fairmonk if you want to experiment with this pull request, you will need to resolve the reported conflicts, compile a local version of the git client plugin, then adapt a private copy of the git plugin to use the new showChangedPath() API's added by this pull request. I've attempted the conflict resolution in #326 if you want to use that as a starting point. When I executed the tests in that conflict resolution case, there were several failures in merge related areas. Since this pull request is making changes in merge related areas, test failures are a cause for concern. Refer to my comments in #326 that this pull request will also require changes in the git plugin before you'll see a different behavior. |
|
@MarkEWaite Thank you Mark. Meanwhile I opted for using excluded regions ( as a workaround ). The excluded regions doesn't seem to have this problem with merge commits from Pull Requests. Of course specifying "everything else" inside excluded regions requires some extra typing ( but since I generate my jobs via DSL plugin and the repository is not changing very often [ in terms of adding new paths ] - it was a matter of adding several if-else statements inside my job template. ) After thorough testing, my workaround is not valid. Merging Pull Requests still triggers build ( even if excluded regions are used and changes fall into excluded regions ). The Excluded/Included regions work fine only with normal commits for me. |
Added a new method showChangedPaths.
This implementation uses
git diff --name-only old...newinstead ofgit logto identify changed paths more accurately.Here's a good explanation on the difference between how
git logandgit diffwork: http://stackoverflow.com/a/7256391I'm hoping this method can be leveraged by the Jenkins git-plugin to filter included/excluded paths which would resolve:
Note: Originally, I was going to implement this using
git log --first-parent, but @nwholloway pointed out that using--first-parentwould cause issues when a user merges code into into a topic branch and pushes the results to master.Note2: I don't develop in Java, so these changes probably need another set of eyes before they're merged.