fix(git-extension): trim trailing whitespace before stripping commit-message quotes#3673
Merged
mnriem merged 1 commit intoJul 23, 2026
Conversation
…message quotes The auto-commit bash and Python twins strip a leading/trailing quote from the configured `message:` value with an end-of-string-anchored quote strip. When the YAML value has trailing whitespace after the closing quote (`message: "Done" `), the close-quote strip is anchored to end-of-string, so it never matches the quote (spaces follow it). The commit message then keeps a dangling quote and trailing spaces (`Done" `). The PowerShell twin already .Trim()s before stripping, so it produced the clean `Done`. This left the three script variants out of parity. Trim the value before stripping quotes in the bash and Python twins so all three agree. Verified at the exact-code level: the old bash sed pipeline yields `spec done" ` and the new one `spec done`; the Python _strip_quotes matches. Add a parity regression test with trailing whitespace after the closing quote (runs under CI where Git bash is resolvable).
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes malformed auto-commit messages when quoted YAML values contain trailing whitespace.
Changes:
- Trims whitespace before quote removal in Bash and Python.
- Adds Bash/Python parity regression coverage.
Show a summary per file
| File | Description |
|---|---|
extensions/git/scripts/bash/auto-commit.sh |
Trims trailing whitespace before stripping quotes. |
extensions/git/scripts/python/auto_commit.py |
Aligns quote stripping with Bash and PowerShell. |
tests/extensions/git/test_git_extension_python_parity.py |
Tests trailing-whitespace message parsing. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Medium
Collaborator
|
Thank you! |
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.
The auto-commit bash and Python twins read the configured
message:value and strip one leading + trailing quote with an end-of-string-anchored strip (sed 's/["\']*$//'/re.sub(r'["\']*$', ...)).When the YAML value has trailing whitespace after the closing quote — e.g.
message: "Done"— the close-quote strip never matches, because the quote is no longer at end-of-string (spaces follow it). The resulting commit message keeps a dangling quote and trailing spaces:Done".The PowerShell twin already
.Trim()s before stripping, so it produced the cleanDone. So the three script variants were out of parity, and two of them wrote a malformed commit subject.Fix
Trim the value before stripping quotes in the bash and Python twins, matching the PowerShell twin.
Verification
Exact-code level (the actual sed pipeline / regex from the scripts):
Python
_strip_quotesmatches after the fix ('spec done'for trailing-space, single-quote, and bare cases).Added a parity regression test (
test_custom_message_with_trailing_whitespace_after_quote) asserting bash and Python produce the same cleanspec done. It runs under CI where Git-for-Windows bash / native bash is resolvable; the existing bash-parity tests already skip on environments without a working native bash.