F1: remote checkout without a remote, git.lastMessage, shared git status store

- vcs: checking out a remote-tracking branch reads remote.<name>.fetch;
  without a matching refspec it creates the local branch with --no-track
  instead of leaving a dirty tree after git fails to set up tracking.
- vcs + engine: git.lastMessage returns HEAD's full message (null before
  the first commit); the Changes window prefills Amend with it.
- ui: stores/vcsStatus.ts is the only git.status caller; the Changes
  window, tree/tab colours and the branch item read its snapshot, so a
  gitChanged costs one status query. RepoSummary carries upstream,
  ahead and behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-27 17:16:53 +01:00
parent d567f3957d
commit 4bdfe521f2
14 changed files with 649 additions and 314 deletions

View file

@ -29,6 +29,7 @@ import {
type ChangedFile,
} from "../../src/components/vcs/changes/changes";
import { useNotificationsStore } from "../../src/stores/notifications";
import { useVcsStatusStore } from "../../src/stores/vcsStatus";
/** A recorded engine call. */
interface Call {
@ -142,6 +143,8 @@ beforeEach(() => {
switch (args.command) {
case "git.status":
return Promise.resolve(gitStatus);
case "git.lastMessage":
return Promise.resolve({ message: "Last subject\n\nLast body" });
case "git.commit":
return Promise.resolve({ commit: "fedcba9876543210", summary: String(args.params.message).split("\n")[0] });
case "file.saveAll":
@ -306,6 +309,35 @@ describe("the Changes store", () => {
expect(changes.amend).toBe(false);
});
it("shares one git.status per gitChanged with the status colours", async () => {
const vcs = useVcsStatusStore(pinia);
vcs.start();
useChangesStore(pinia).start();
await flushPromises();
expect(callsOf("git.status")).toHaveLength(1);
await emit({ kind: "gitChanged", available: true, repo: null, filesChanged: true });
expect(callsOf("git.status")).toHaveLength(2);
expect(vcs.colourOf("tmp.txt")).toBe("untracked");
vcs.stop();
});
it("prefills an empty box with the last message on Amend and empties it again", async () => {
const changes = useChangesStore(pinia);
await changes.refresh();
changes.amend = true;
await flushPromises();
expect(callsOf("git.lastMessage")).toHaveLength(1);
expect(changes.message).toBe("Last subject\n\nLast body");
changes.amend = false;
await flushPromises();
expect(changes.message).toBe("");
changes.message = "mine";
changes.amend = true;
await flushPromises();
expect(changes.message).toBe("mine");
expect(callsOf("git.lastMessage")).toHaveLength(1);
});
it("keeps the message when git refuses the commit", async () => {
const changes = useChangesStore(pinia);
await changes.refresh();