feat(module): pin module version (version field, ?ref=, --ref)#39
Open
rickliujh wants to merge 2 commits into
Open
feat(module): pin module version (version field, ?ref=, --ref)#39rickliujh wants to merge 2 commits into
rickliujh wants to merge 2 commits into
Conversation
A git module previously always cloned its source's default branch, so a run tracked whatever was on main. Add version pinning to a branch, tag, or commit: - spec.modules[].version — a visible, templatable field on child module references (the preferred form). - ?ref=<version> — a Terraform-style suffix on the source string, for the CLI/root source (which has no modules[] entry to hold a field). Also accepted in a child source; the version field takes precedence. ResolveSource takes an explicit version and combines it with any ?ref= suffix, then clones in full and checks out the ref via a new git.Checkout (go-git ResolveRevision with git-CLI fallback). Pinning a local source is an error. Documented as spec rule M5 with referencing tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The version field covers child modules, but the root module is named on the command line and had no field. Add a short --ref flag to `loom run` and `loom diff` that pins the root source to a git branch, tag, or commit. It threads through the same ResolveSource path and takes precedence over a ?ref= suffix on the source. Co-Authored-By: Claude Opus 4.8 <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.
What
A git module previously always cloned its source's default branch, so a run tracked whatever was on
mainat the time. This adds a way to pin a module to an exact branch, tag, or commit so runs are reproducible.Three ways to set it, one for each place a module is named:
version:field alongsidename/source/params(the preferred form), templatable:--refflag onloom run/loom diff:?ref=suffix on any git source (Terraform convention), for the root or a childsource:loom run 'https://github.com/org/modules.git//onboard?ref=v1.4.0'Precedence:
--refflag →versionfield →?ref=suffix. Pinning a local source is an error (already fixed on disk).How
config.ModuleRefgains a templatableVersionfield, validated like other templatable fields.module.ResolveSource(source, version, parentDir, logger)takes an explicit version and merges it with any?ref=suffix (explicit wins), clones in full, then checks out the ref.git.Checkout— go-gitResolveRevision+ checkout, with agit checkoutCLI fallback (resolves refs go-git can't, e.g. remote-tracking branches). NoRepositoryinterface change.modules[].versionwith the parent's params and passes it down.--refflag added toloom runandloom diff, threaded toResolveSource(flag beats a?ref=suffix).Spec & docs
specs/module.md, plus updates to the child-module inputs table, source-pattern table, the T4 templatable list, the run/diff flag tables, and the execution flow.module-composition,loom-yaml,cli-run,cli-diff).Tests
git.Checkouttag checkout (go-git and CLI paths) + unknown-ref error.version-field resolution, field-overrides-?ref=precedence, and local-source rejection for both spellings.--refpins the root source (cmdtest).go vetclean.Verified end-to-end against a real repo: child
version:default → v1 content;-p modVersion=v2→ v2 content;--ref v1on the root → v1 content;--refoverrides?ref=; bogus version →pinning module "..." to version "v9": git checkout v9: exit status 1.🤖 Generated with Claude Code