Skip to content

fix: preserve all commit marks (Fixes/PMS/Log/etc.) when using --amend#19

Merged
zccrs merged 4 commits intomasterfrom
copilot/fix-git-commit-helper-amend
Feb 25, 2026
Merged

fix: preserve all commit marks (Fixes/PMS/Log/etc.) when using --amend#19
zccrs merged 4 commits intomasterfrom
copilot/fix-git-commit-helper-amend

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

  • Understand the issue: commit --amend loses Fixes: and PMS: issue references from the original commit
  • Implement fix: preserve ALL marks from original commit in --amend mode (excluding Change-Id: which is already handled separately by append_change_id)
    • Covers Fixes:, PMS:, Log:, and any other single-line mark fields
    • Skips marks already present in the AI-generated content (no duplicates)
    • Providing --issues explicitly still overrides the preserved references
  • Refactor: move all amend-specific mark preservation into a clean, standalone if amend { ... } block (separate from the --issues handling), consolidating both mark preservation and Change-Id into one place
  • All 19 tests pass
Original prompt

This section details on the original issue you should resolve

<issue_title>git-commit-helper commit --amend 会把issues关联丢弃</issue_title>
<issue_description>git-commit-helper commit --amend 执行时,应该是保存上次提交日志内容。</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

When using `git-commit-helper commit --amend`, issue references
(Fixes: and PMS:) from the original commit were being lost because
the AI-generated message didn't always include them.

Now, when --amend is used without explicitly providing new --issues,
the tool extracts Fixes: and PMS: marks from the original commit
message and appends any missing ones to the new commit message.
The Change-Id preservation logic already existed and is unchanged.

Co-authored-by: zccrs <13449038+zccrs@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix git-commit-helper to preserve issue associations on amend fix: preserve Fixes:/PMS: issue references when using --amend Feb 25, 2026
Copilot AI requested a review from zccrs February 25, 2026 06:13
@zccrs zccrs marked this pull request as ready for review February 25, 2026 07:13
… issue refs

Expand the amend mark preservation from only Fixes:/PMS: to all marks
from the original commit (excluding Change-Id which is already handled
by append_change_id). This ensures Log:, Fixes:, PMS:, and any other
single-line marks are retained when amending a commit.

Co-authored-by: zccrs <13449038+zccrs@users.noreply.github.com>
Copilot AI changed the title fix: preserve Fixes:/PMS: issue references when using --amend fix: preserve all commit marks (Fixes/PMS/Log/etc.) when using --amend Feb 25, 2026
Copilot AI requested a review from zccrs February 25, 2026 07:17
Separate the mark preservation logic from the --issues parameter check.
Instead of nesting in `else if amend`, use a standalone `if amend { ... }`
block that handles all amend-specific mark preservation (including
Change-Id) in one place, after the --issues handling.

Co-authored-by: zccrs <13449038+zccrs@users.noreply.github.com>
Copilot AI requested a review from zccrs February 25, 2026 07:24
@zccrs zccrs merged commit 1bfaea9 into master Feb 25, 2026
10 checks passed
@zccrs zccrs deleted the copilot/fix-git-commit-helper-amend branch February 25, 2026 08:16
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.

git-commit-helper commit --amend 会把issues关联丢弃

2 participants