[rush] Change getChangedFiles to pass ref only in git diff #4678
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.
This is to avoid git determining merge base of given ref and current head
Summary
Related to #4589 but for
rush change --verify --no-fetch --target-branch <ref>
In CI, I have the SHA of merge base given by the CI runner at env variable (
$CI_MERGE_REQUEST_DIFF_BASE_SHA
), so I run the following command.However that will fail with the following output:
Details
I figured out that the failing codes was here in the getChangedFiles function:
rushstack/libraries/rush-lib/src/logic/Git.ts
Lines 277 to 294 in 49d93a9
From my understanding from reading
git diff
docs and this StackOverflow question, to retrieve a list of changed files between the given ref (branch/commit/tag/etc) and current HEAD, I do not need to retrieve the merge base (and hence do not need to be in the style ofA...B
which Git will determine the merge base)From my investigation of Rush's history, it seemed like it was added this way since 2016, so I'm not sure what's the intention there:
4a4de9a#diff-26c82d4767d5297bb1f9e2d6c4329b25a0f60cd6b99c5d8d59c4ac7e14a04320R22
How it was tested
Manual test: I build Rush locally with this change and able to get that command (
rush change --verify --no-fetch --target-branch <<REDACTED_MERGE_BASE>>
) working on my local repro.Impacted documentation