Repository navigation
Conversation
…quoted GetAffectedFiles parsed `git diff --name-only` line output, where git C-quotes paths containing characters such as `"` or non-ASCII bytes. The quoted string never matched protected file patterns, so pushes and merges touching such files bypassed them. Use -z and split on NUL, and stop trimming whitespace from real file names. Assisted-by: Codet:claude
Assisted-by: Codet:claude
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
| // Run `git diff --name-only` to get the names of the changed files | ||
| cmd := gitcmd.NewCommand("diff", "--name-only").AddDynamicArguments(oldCommitID, newCommitID) | ||
| // "-z" keeps paths raw, otherwise git quotes special characters and they can no longer match path patterns | ||
| cmd := gitcmd.NewCommand("diff", "--name-only", "-z").AddDynamicArguments(oldCommitID, newCommitID) |
There was a problem hiding this comment.
There are already a lot of "diff --name-only" commands.
For example: why not refactor and reuse GetFilesChangedBetween?
Assisted-by: Codet:claude
Assisted-by: Codet:claude
Assisted-by: Codet:claude
| } | ||
|
|
||
| // GetFilesChangedBetweenWithEnv is like GetFilesChangedBetween but runs git with extra env (e.g. a pre-receive quarantine) | ||
| func (repo *Repository) GetFilesChangedBetweenWithEnv(ctx context.Context, base, head string, env []string) ([]string, error) { |
There was a problem hiding this comment.
I don't think it is right to keep adding new special functions into "*Repository".
And I don't think it is right to expose "env" in a public function to callers.
-> refactor(git): parse git stdout correctly - #40326
|
Everything should have been addressed in #40326 The new test is not necessary because |
GetAffectedFilesparsedgit diff --name-onlyline output, where git C-quotes paths containing characters such as"or non-ASCII bytes. The quoted string never matched protected file patterns, so pushes and merges touching such files bypassed them.It now reuses
GetFilesChangedBetween(NUL-separateddiff-tree) and no longer trims whitespace from real file names. Asdiff-treedoes no rename detection, a rename now reports both the old and the new path, so protected patterns also match the old path. The PR diff view marks a renamed file as protected by its old path too.