From ced8655afe0d34611ea37abc11279f75dec553fc Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 26 Nov 2026 20:09:01 +0800 Subject: [PATCH] fix(vcs): load no Amend message with several repositories With several roots, Amend loaded HEAD's message of the repository last selected in the branch widget, log or push dialog, whatever the included files were, and the commit then amended every included repository with it. As in IDEA, the commit to amend is ambiguous there: no message is loaded, and the one typed amends each repository's HEAD. Fixes #6149 --- src/features/vcs/__tests__/commitDraft.test.ts | 10 ++++++++++ src/features/vcs/commitStore.ts | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/features/vcs/__tests__/commitDraft.test.ts b/src/features/vcs/__tests__/commitDraft.test.ts index a2f25691f..c9a4e7754 100644 --- a/src/features/vcs/__tests__/commitDraft.test.ts +++ b/src/features/vcs/__tests__/commitDraft.test.ts @@ -221,6 +221,16 @@ describe("commit message draft (#4423)", () => { expect(useCommit.getState()).toMatchObject({ author: "", authorDate: scoped.authorDate, amend: false }); }); + it("loads no message for Amend with several repositories (#6149)", async () => { + useVcs.setState({ root: "/a", roots: ["/a", "/a/b"] }); + type("my draft"); + await setAmend(true); + expect(vcsLog).not.toHaveBeenCalled(); + expect(useCommit.getState()).toMatchObject({ amend: true, message: "my draft" }); + await setAmend(false); + expect(useCommit.getState()).toMatchObject({ amend: false, message: "my draft" }); + }); + it("keeps the typed draft, not the amended commit's message, while Amend is on", async () => { type("my draft"); flushDraft(); diff --git a/src/features/vcs/commitStore.ts b/src/features/vcs/commitStore.ts index e8e2af287..37a58420e 100644 --- a/src/features/vcs/commitStore.ts +++ b/src/features/vcs/commitStore.ts @@ -449,6 +449,9 @@ export async function setAmend(on: boolean, target: EarlierAmend | null = null) if (data) scheduleDraft(); return; } + // With several repositories the commit to amend is ambiguous: as in IDEA, no message is + // loaded, and the one typed amends each repository's HEAD. + if (!target && roots.length > 1) return; const current = () => request === amendRequest && useCommit.getState().amend && useVcs.getState().root === project; let head = target?.commit; try {