Skip to content

Accept git+ sources for the sync/prune env-definition positional - #216

Merged
OwenPriceSkelly merged 1 commit into
mainfrom
sync-git-source
Aug 13, 2026
Merged

Accept git+ sources for the sync/prune env-definition positional#216
OwenPriceSkelly merged 1 commit into
mainfrom
sync-git-source

Conversation

@OwenPriceSkelly

Copy link
Copy Markdown
Member

Summary

rootstock sync and rootstock prune take an optional positional source of env definitions; until now it had to be a local staging directory. This adds a second form — a pip-style git spec:

rootstock sync 'git+https://github.com/Garden-AI/rootstock.git@main#subdirectory=sample_model_configurations/nvidia_configs' --cluster delta

REF may be a branch, tag, or full commit SHA (omitted = the remote default branch); subdirectory defaults to the repo root. This lets a cluster converge straight from the catalog repo, skipping the scp/staging round-trip.

How

  • New rootstock/gitsource.py: spec parsing plus a shallow fetch (init + fetch --depth 1 + detached FETCH_HEAD checkout — one code path that covers branch/tag/SHA refs, unlike clone --branch) into a temp dir removed at process exit. That lifetime is sufficient: the planner hashes the staged files and the build phase copies them into the install root, so nothing durable lives in the checkout.
  • Shared resolve_source_arg in commands/common.py dispatches git specs vs. local dirs; the sync and prune adapters both use it, preserving the existing contract (unusable source → exit 2).
  • Everything downstream of resolution is untouched — the checkout flows through the same source_dir path the planner already had.
  • Clean usage errors for: missing git binary, malformed specs, unknown fragment options, refs that don't exist (git stderr attached), and subdirectory values that are missing or escape the repo.

Testing

  • tests/test_gitsource.py: parse cases (ssh userinfo vs. ref @, branch names with /, malformed specs) and real fetches against a local repo over file:// (default branch, tag, SHA, subdirectory, error paths).
  • tests/cli/test_sync.py: adapter wiring (git spec materialized before planning; fetch failure → exit 2).
  • Full tests/cli + tests/commands suites pass (304 tests); ruff check/format and ty clean.
  • Manual end-to-end: dry-run sync from a scratch git+file://…#subdirectory=environments repo produced the expected build/download plan.

🤖 Generated with Claude Code

Besides a local staging directory, sync and prune now take a pip-style
git spec — git+URL[@ref][#subdirectory=DIR] — shallow-fetched (init +
fetch --depth 1 + detached FETCH_HEAD checkout, so branch, tag, and
full-SHA refs all work) into a temp checkout that lives until process
exit, then fed through the existing local-dir path unchanged. Lets a
cluster converge straight from the catalog repo without an scp step.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@OwenPriceSkelly
OwenPriceSkelly merged commit fcf2fe4 into main Aug 13, 2026
5 checks passed
@OwenPriceSkelly
OwenPriceSkelly deleted the sync-git-source branch August 13, 2026 20:21
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