Fix rules:changes net diff for reverted files in MR pipelines
What does this MR do and why?
Fixes rules:changes firing for files that were changed and then reverted within an MR (when compare_to isn't set).
MergeRequest#changed_pathsused to union the changes from every commit in the MR, so a file touched in one commit and reverted in another stayed "changed" forever and kept triggeringrules:changes- Now it computes a single net tree diff between the MR's base and head (
FindChangedPathswith abase..headtree pair), so reverted files cancel out. This matches the documented behavior and the existingcompare_topath - Still uses the same
git-diff-treeGitaly RPC, so it's not subject to diff display limits (keeps the #433257 (closed) fix intact) and doesn't go back to the slowdiff_statspath. - Behind the
mr_changed_paths_net_difffeature flag
References
Relates to #597640
How to set up and validate locally
- Turn
:mr_changed_paths_net_difffeature on - In a test project, create
my_file.txton master. - Add .
gitlab-ci.yml:
rules-changes-test:
script: echo "foo bar"
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: [my_file.txt]- Branch off, open an MR, then push a commit changing
my_file.txt, then a commit reverting it to the original content.- The latest MR pipeline should not contain
rules-changes-test.
- The latest MR pipeline should not contain
- Turn feature off and retest, the job shows up
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #597640
Edited by Tarun Raja