Move clone/snapshot logic onto RhizaTemplate; remove redundant _sync_helpers functions#379
Merged
Move clone/snapshot logic onto RhizaTemplate; remove redundant _sync_helpers functions#379
Conversation
Co-authored-by: tschm <2046079+tschm@users.noreply.github.com>
…helpers functions Co-authored-by: tschm <2046079+tschm@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Simplify sync command implementation
Move clone/snapshot logic onto RhizaTemplate; remove redundant _sync_helpers functions
Mar 8, 2026
Member
|
@copilot: Should be enough to return RhizaTemplate from the _validate... function |
Co-authored-by: tschm <2046079+tschm@users.noreply.github.com>
Contributor
Author
Done in 22e337b. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ilures Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sync.pyorchestrated cloning and snapshot preparation through a chain of free functions (_construct_git_url,_clone_and_resolve_upstream,_excluded_set,_prepare_snapshot) imported from_sync_helpers. These belong on the model that owns the configuration.Changes
RhizaTemplate— three new membersgit_url(property) — constructs the HTTPS clone URL fromtemplate_repository+template_host; raisesValueErrorfor unsupported hosts or missing repoclone(git_executable, git_env, branch="main")— sparse-clones upstream, resolves bundle names → file paths, mutatesself.include; returns(upstream_dir, upstream_sha)snapshot(upstream_dir, snapshot_dir)— builds the exclude set fromself.exclude, copies included files intosnapshot_dir; returns(materialized, excludes)All three use deferred (function-body) imports to break the circular dependency with
_sync_helpers._validate_and_load_template— simplified return typeChanged from returning a 5-tuple
(template, rhiza_repo, rhiza_branch, include_paths, excluded_paths)to returningRhizaTemplatedirectly. The CLIbrancharg is applied as a fallback (template.template_branch = branch) inside the function when no ref is set intemplate.yml.sync.py— dramatically simplifiedAll downstream values (
repo,host,ref, etc.) are read directly fromtemplate.*attributes — no local alias variables remain insync.py._sync_helpers.py— dead code removed_construct_git_urland_clone_and_resolve_upstreamentirely_excluded_setand_prepare_snapshotremain as private helpers used internally by_merge_with_baseload_bundles_from_clone/resolve_include_pathsimport (now imported directly frombundle_resolverinsidemodels.py)materialize.pyRemoved
_construct_git_urlfrom re-exports.Tests
TestConstructGitUrlfromtest_sync.py; updatedTestCloneAndResolveUpstreamWithTemplatesto exerciseRhizaTemplate.clonedirectlysync._clone_and_resolve_upstreamupdated to patchRhizaTemplate.cloneTestValidateAndLoadTemplateupdated to assert on the returnedRhizaTemplatedirectly; addedtest_branch_fallback_applied_when_template_branch_unsetTestRhizaTemplateGitUrl,TestRhizaTemplateClone,TestRhizaTemplateSnapshottotest_models.pyOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.