Skip to content

feat: report drift in status and add dryRun to pull and push - #106

Open
Rahulsharma0810 wants to merge 1 commit into
iHildy:mainfrom
Rahulsharma0810:feat/status-drift-dry-run
Open

Rahulsharma0810 wants to merge 1 commit into
iHildy:mainfrom
Rahulsharma0810:feat/status-drift-dry-run

Conversation

@Rahulsharma0810

Copy link
Copy Markdown

Closes #100

What

  • status gets two new lines:
    • Local changes: how many synced files differ from what the repo holds (or none).
    • Remote: up to date, N commit(s) not yet pulled, N local commit(s) not yet pushed, or unreachable.
  • pull and push accept dryRun: true. They list what would change and change nothing.
  • Real pull and push runs now end with a per-file summary, for example 2 files: 1 updated, 1 added followed by update config/opencode.json lines (capped at 15).

How

  • Remote drift uses a new read-only inspectRemoteDrift(): git fetch --prune, rev-list --left-right --count, and git diff --name-status HEAD origin/<branch>. It never moves the branch or the working tree, unlike fetchAndFastForward.
  • Local drift and push dry run stage the local config into a throwaway sparse clone of the sync repo (config/ and state/ only) with the existing syncLocalToRepo, then read that clone's git status. This reuses the exact push logic (secret scrubbing, overrides, extra paths), does not touch the real sync repo or config, and does not write the overrides file. The scratch directory is always removed.
  • Only file paths and counts are printed, never contents.

Limits

  • Session data and secret files are not compared (they are filtered out of the preview), and the output says so.
  • Local changes is unknown when the plugin's clone has pending changes, because the comparison would not be meaningful.
  • Paths in a pull dry run are repository paths (config/...), not local paths.
  • status now does a network fetch. It fails soft with Remote: unreachable.

Tests

  • preview.test.ts: summary formatting (counts, porcelain and name-status input, renames, truncation).
  • service.test.ts: two machines against a local bare remote. Edit locally, status shows the drift while Working tree stays clean; push dry run lists the file and leaves the remote and local files untouched; a real push summarises; the other machine's status shows the remote ahead; pull dry run lists the change without applying it; a real pull summarises; a final dry run reports up to date.
  • bun run check, bun run test (211 passing) and bun run build pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

status cannot show drift between local config and the repo; add dry-run and change summary

1 participant