Fix: Reverse git diff direction to correctly detect renamed files with -M95#347
Open
chandprashant92 wants to merge 1 commit intodropbox:mainfrom
Conversation
…h -M95 Fix: Reverse git diff direction to correctly detect renamed files with -M95
Author
|
Hi @joshafeinberg, would you mind reviewing my changes, please? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug:
git diff HEAD..merge-basesilently misses all affected moduleswhen a PR contains only pure file renames
Problem
GitChangedFilesSourceconstructs the changed-files command as:git --no-pager diff --name-only -M95 $top..$sha
Where
top = "HEAD"(the PR tip) andsha= the merge-base commit.This produces:
git diff --name-only -M95 HEAD..merge-base
The direction is reversed. The semantically correct command for
"what changed in this PR?" is
merge-base..HEAD.Why this is silent for normal PRs (and why it was never caught)
For content-modified files,
git diff A..Bandgit diff B..Areportthe same filenames — direction doesn't affect
--name-onlyoutput.The bug only surfaces when a PR consists entirely of pure renames
(files moved via
git mvwith 100% content similarity). In that case,-M95rename detection kicks in and--name-onlyoutputs thedestination path relative to the diff direction:
--name-onlyoutputgit diff merge-base..HEADgit diff HEAD..merge-baseWith the reversed direction, AMD receives a list of file paths that no
longer exist in the project tree →
changedProjects = 0,unknownFilesaccumulates all renamed files → the
buildAllWhenNoProjectsChangedsafety net is not triggered (because
unknownFilesis non-empty) →AMD reports 0 affected modules and silently skips all tasks.
Reproduction