Skip to content

feat(workspace): add standalone workspace sync - #19

Merged
reckerp merged 5 commits into
mainfrom
feat/workspace-sync
Jun 29, 2026
Merged

feat(workspace): add standalone workspace sync#19
reckerp merged 5 commits into
mainfrom
feat/workspace-sync

Conversation

@reckerp

@reckerp reckerp commented Jun 29, 2026

Copy link
Copy Markdown
Owner

What

Adds gx workspace sync, a manual copy tool for moving setup files (e.g. .env) between specific workspaces. It complements gx workspace setup, which applies the configured policy to the current workspace; sync lets you copy arbitrary paths between arbitrary workspaces.

gx workspace sync                                   # main worktree -> current workspace, configured copy_files
gx workspace sync <target>                          # main worktree -> <target>
gx workspace sync <target> .env config/local.toml   # explicit paths
gx workspace sync <target> --from staging .env.local # explicit source
gx workspace sync --dry-run feat-x .env             # preview, no writes

Defaults

  • Target defaults to the current workspace.
  • Source defaults to the main worktree.
  • Paths default to the configured setup copy_files (global config plus the repo profile, deduped) — the same set workspace creation/setup uses.

Behavior

  • Source and target accept workspace names, branch names, fuzzy queries, or absolute paths, resolved through the same fuzzy matcher as gx workspace go.
  • Directories are copied recursively; parent directories are created as needed.
  • Missing source paths are summarized as a warning but do not abort the rest of the sync.
  • Syncing a workspace to itself is refused.
  • --dry-run reports what would be copied without writing anything.
  • All human-readable output goes to stderr; this command does not participate in shell navigation, so stdout stays clean.

Why

Setup files sometimes need to be copied after workspace creation, or pulled from a non-main workspace. Previously only the configured setup flow was available, with no way to sync arbitrary paths between specific workspaces.

How it was built

  • Reuses the existing copy/glob logic in src/repo_setup.rs. A new sync_paths primitive adds dry-run support and reports patterns that matched no source path (rather than silently skipping them), returning a CopyOutcome { copied, missing }.
  • Reuses the existing fuzzy workspace resolution and paths_equal helpers in src/commands/workspace.rs; a small resolver maps a query/branch/absolute path to a worktree root.
  • Drops the now-unused sync alias on workspace update so it no longer collides with the new subcommand.

Testing

  • cargo build — passes, no warnings.
  • cargo clippy — clean.
  • cargo test — 141 passed, 0 failed.

New tests cover:

  • Defaults and self-sync guard (resolver + paths_equal).
  • Resolver accepts fuzzy name/branch queries, known absolute worktree paths, and existing absolute directories; rejects unknown queries and nonexistent absolute paths.
  • sync_paths copies files and directories, creates parent dirs, dry-run writes nothing, missing paths are summarized (non-fatal), and overlapping patterns are deduped.

reckerp added 5 commits June 29, 2026 21:46
…ing-path reporting

Add a copy helper that, unlike copy_setup_files, records patterns that
matched no source path instead of silently skipping them, and supports a
no-write dry run. Directories are copied recursively, parent directories
are created as needed, and matches are deduped in pattern order. This is
the primitive backing `gx workspace sync`.
Add the CLI surface for syncing files between workspaces: an optional
target, optional repo-relative paths, a --from source override, and
--dry-run. Drop the `sync` alias from `workspace update` so it no longer
collides with the new subcommand.
Add run_sync plus a source/target resolver that accepts workspace names,
branch names, fuzzy queries, or absolute paths. Target defaults to the
current workspace, source to the main worktree, and paths to the
configured copy_files (global config plus the repo profile, deduped).
Syncing a workspace to itself is refused. All human-readable output goes
to stderr since this command does not participate in shell navigation.
# Conflicts:
#	README.md
#	src/args.rs
#	src/commands/workspace.rs
@reckerp
reckerp merged commit dab5512 into main Jun 29, 2026
6 checks passed
@reckerp
reckerp deleted the feat/workspace-sync branch June 29, 2026 20:37
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.

1 participant