Fix GitClientTest.test git diff when diff.noprefix=true is used #9947
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.
What Does This Do
This adds
--no-prefixwhenShellGitClientrunsgit diff, updates the regex inGitDiffParser, and adjusts test files.Motivation
When
diff.noprefix=true(or other git diff parameters that change the prefix format) used, it changes the output fromgit diffand and the test failure below is seen inGitClientTest.test git diff. I have used this git setting in my~/.gitconfigfile for years as it makes copying and pasting file names simpler.Additional Notes
Setting
diff.noprefix=truechanges the file name pattern and it fails to matchGitDiffParser.CHANGED_FILE_PATTERN.Notice the lack of
a/andb/on the latter output, but you'll see that the pattern expects that:The simple workaround is to pass
--default-prefixtogit diff, however this option has only been present since 2023: git/git@b39a569A safer option would be to use
--no-prefix, which has existed since 2007: git/git@eab9a40To reproduce this error, you can run the test this way:
Contributor Checklist
type:and (comp:orinst:) labels in addition to any useful labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]