Skip to content

fix(git-extension): trim trailing whitespace before stripping commit-message quotes#3673

Merged
mnriem merged 1 commit into
github:mainfrom
Quratulain-bilal:fix/auto-commit-message-trim-parity
Jul 23, 2026
Merged

fix(git-extension): trim trailing whitespace before stripping commit-message quotes#3673
mnriem merged 1 commit into
github:mainfrom
Quratulain-bilal:fix/auto-commit-message-trim-parity

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

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 clean Done. 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):

input:    message: "spec done"
OLD bash: [spec done"  ]      # dangling quote + spaces
NEW bash: [spec done]         # clean

Python _strip_quotes matches 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 clean spec 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.

…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).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mnriem
mnriem merged commit 6e8623b into github:main Jul 23, 2026
14 checks passed
@mnriem

mnriem commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants