feat(git): sync with a remote — fetch, pull and push

Add remote sync to the Git panel: set/edit an origin URL, then fetch, pull
(fast-forward) and push, with live ahead/behind counts against the
remote-tracking branch.

Backend:
- git_ops: remote_status (git2 ahead/behind + upstream), set_remote, and
  fetch/pull/push that shell out to the system git CLI so they reuse the
  user's existing credentials (SSH agent, keychain / credential helpers)
  instead of reimplementing libgit2 credential callbacks. Pull is --ff-only
  to avoid leaving a conflicted tree from the GUI; push uses --set-upstream.
- New commands git_remote_status/set_remote/fetch/pull/push, registered.
- Test: push to a bare local remote, then assert upstream + ahead/behind.

Frontend:
- RemoteStatus type, api wrappers, store state (remote, syncing) with
  refreshRemote wired into refreshGit; pull reloads diagrams + open buffer.
- GitPanel remote section: URL, ahead/behind badges, Fetch/Pull/Push, and a
  set-remote dialog.

cargo test (7 passing incl. roundtrip), svelte-check and build all green.
This commit is contained in:
2026-05-22 21:32:48 +03:00
parent 6f23c620c1
commit c35960761b
9 changed files with 484 additions and 2 deletions

View File

@@ -20,6 +20,11 @@ TypeScript** frontend using **CodeMirror 6** and **Mermaid 11**.
- **Git version control built in** — view the working-tree status, write commit
messages, browse history, create branches and switch between them. Each branch
keeps its own set of diagrams, just like normal Git.
- **Remote sync** — point a project at a remote (`origin`), then **fetch**,
**pull** (fast-forward) and **push** from the Git panel, with live ahead/behind
counts. Network operations shell out to your system `git`, so they reuse your
existing credentials (SSH agent, keychain / credential helpers) — no separate
login.
- **Optimize panel (Diagram Doctor)** — analyse a tangled flowchart and declutter
it in one click: a readability score and metrics (hubs, density, cross-group
edges), plus source rewrites for the **ELK layered layout**, extra
@@ -132,6 +137,10 @@ cd src-tauri && cargo test
for you. Switching branches reloads the diagram list from that branch.
- **History** shows the most recent commits with short SHA, message, author and
relative time.
- **Remote sync** sets/uses an `origin` remote. Fetch updates remote-tracking
refs; pull is fast-forward only (it never leaves a half-merged tree from the
GUI — reconcile divergent history yourself); push uses `--set-upstream`. These
invoke the system `git` binary, which must be installed and on `PATH`.
## License