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
Цей коміт міститься в:
l0ng-ai committed 2026-11-26 20:09:01 +08:00
1 джерело f2a372428c
коміт ced8655afe
2 files changed
+13

No files matched your search

+10
Переглянути файл
@@ -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();
+3
Переглянути файл
@@ -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 {