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 {