arturobernalg opened a new pull request, #1426:
URL: https://github.com/apache/maven-scm/pull/1426

   Fixes #1196.
   
   `GitStatusConsumer` (the gitexe provider's `git status --porcelain` parser) 
only has patterns for `A`/`M`/`D`/`R` status codes. A line for an untracked 
file (`?? path`) matches none of them, so it falls into the default branch, is 
logged at warn level ("Ignoring unrecognized line"), and is never added to the 
changed-files list.
   
   `ScmCheckModificationsPhase`, which backs `release:prepare`'s 
local-modification check, fails the release when 
`StatusScmResult.getChangedFiles()` is non-empty. Since untracked files never 
make it into that list for the GitExe provider, a release can proceed even 
though the working tree has untracked content that should have blocked it, as 
described in the issue.
   
   I reproduced this with a real git repository (an untracked file produces 
exactly `?? newfile.txt` from `git status --porcelain`, confirming the regex 
needed) and with the existing unit test infrastructure, which actually already 
encoded the bug: `testConsumerUntrackedFile` asserted that a `?? project.xml` 
line produced zero changed files.
   
   The fix adds a pattern for `?? <path>` lines and reports them with 
`ScmFileStatus.UNKNOWN`, the status this class already uses for "in the working 
tree but not versioned" - exactly what the javadoc on that constant describes. 
`ScmCheckModificationsPhase` already excludes 
`release.properties`/`pom.xml.releaseBackup`/etc. from the check regardless of 
status, so the "the release plugin's own working files shouldn't fail the 
check" concern raised in the issue is already handled downstream without 
further changes.
   
   Two existing test fixtures (`gitstatus2.gitlog`, and 
`gitstatus-empty.gitlog`, which turns out to contain only `??` lines) embed 
untracked-file lines that were previously silently dropped; I updated their 
expected counts/statuses to match the corrected behavior, and added dedicated 
tests for the new code path (including the existing directory/no-file and 
directory/with-file conventions used by the other status tests in this class).
   
   ---
   
   To make clear that you license your contribution under the [Apache License 
Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) check 
one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [ ] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   https://claude.ai/code/session_0153qyh22xBMN1vPfWGz3jSH


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to