Skip to content

feat: support Git source URLs in collection YAML - #37

Merged
pavelanni merged 11 commits into
mainfrom
feature/collection-install-git-sources
May 1, 2026
Merged

pavelanni merged 11 commits into
mainfrom
feature/collection-install-git-sources

Conversation

@pavelanni

@pavelanni pavelanni commented May 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add source: field to collection YAML SkillRef for Git repo URLs, mutually exclusive with image:
  • Add skillctl collection install subcommand that installs skills from a collection YAML (-f local file or positional Git URL) into agent skill directories (--target or -o)
  • Source entries: clone → build → install with SHA-based skip logic via git ls-remote
  • Image entries: pull from registry with digest-based skip logic; --force overrides both

Test plan

  • pkg/collection/ unit tests: source field parsing, mutual exclusivity, optional name validation
  • pkg/source/ unit tests: LsRemote returns SHA, errors on bad ref
  • internal/cli/ tests: input validation, target resolution, invalid YAML, validation errors
  • Full test suite passes (make test)
  • Linter passes (make lint)
  • Smoke test: skillctl collection install --help shows correct flags
  • Manual test: install from local collection YAML with image entries
  • Manual test: install from collection YAML with source entries pointing to Git repos

Closes #35

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a collection install command to install skills from collection manifests.
    • Example collection manifest demonstrating both Git-based and OCI image-based skills.
  • Improvements

    • Collection validation strengthened to require either a Git source or image per skill and enforce naming rules.
    • More robust Git handling for subpath clones and remote-ref resolution to improve install reliability.
  • Tests

    • Added unit and end-to-end tests covering collection install, parsing/validation, and Git resolution.

pavelanni added 7 commits May 1, 2026 15:15
Add Source field to SkillRef struct for Git URL references.
Update Validate() to enforce mutual exclusivity between image
and source fields. Name is optional for source entries (derived
at install time from SKILL.md frontmatter).

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
LsRemote queries a remote Git repo for the commit SHA of a ref
without cloning. Used by collection install to skip unchanged
source entries.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Export WriteProvenance and NewSkillCardFromRef so the collection
install command can reuse them.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Implements skillctl collection install with support for both
image: (OCI registry) and source: (Git URL) entries. Includes
SHA/digest-based skip logic and --force flag to override.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Tests input validation, target resolution, invalid YAML handling,
and mutual exclusivity validation for the collection install
command.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Shows mixed source: (Git URL) and image: (OCI ref) entries in
a collection YAML for the development workflow.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Pull from remote first, then compare remote digest against
installed digest. Fixes bug where stale local store would
cause collection install to incorrectly skip image updates.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@coderabbitai

coderabbitai Bot commented May 1, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@pavelanni has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 13 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 09e77745-de8b-4b85-ab74-95a100f3aad9

📥 Commits

Reviewing files that changed from the base of the PR and between a1ce907 and 984fce6.

📒 Files selected for processing (1)
  • internal/cli/collection.go
📝 Walkthrough

Walkthrough

Adds a new collection install CLI command and example manifest, extends collection schema to support source (Git) entries alongside OCI image, adds Git utilities (LsRemote) and sparse-clone fallbacks, exports provenance/skill-card helpers, and updates tests to cover new behaviors and validations. (50 words)

Changes

Cohort / File(s) Summary
Collection Install CLI
internal/cli/collection.go, internal/cli/collection_install_test.go
New collection install command: loads collection YAML (file or Git URL), validates entries, creates destination, and installs skills. Handles Git source: entries (resolve ref, clone/build, unpack) and OCI image: entries (pull, unpack). Tests cover missing source/target, invalid YAML, and conflicting image+source.
Collection Schema
pkg/collection/collection.go, pkg/collection/collection_test.go
Adds optional source field to SkillRef; makes name/image omitempty. Reworks validation so each skill must specify exactly one of image or source, and name is required when image is present. Adds tests for parsing and validation.
Git Remote Utility
pkg/source/lsremote.go, pkg/source/lsremote_test.go
Adds LsRemote(ctx, cloneURL, ref) to run git ls-remote (checking git availability), parse commit SHA, and return clear errors with credentials stripped. End-to-end tests against a public repo validate SHA return and missing-ref error handling.
Clone/Resolve Behavior
pkg/source/clone.go, pkg/source/source.go
Adds CloneOptions.DisableSparse and wires it through clone flow. Resolve now retries discovery by re-cloning with sparse disabled when a sparse checkout may produce broken symlinks for a provided subPath.
Provenance & Exported Helpers
internal/cli/install.go, internal/cli/install_test.go, internal/cli/upgrade.go
Exports two previously private helpers (writeProvenance → WriteProvenance, newSkillCardFromRef → NewSkillCardFromRef) and updates call sites to use exported names so collection install can reuse provenance and skill-card creation logic.
Examples
examples/dev-collection.yaml
Adds sample SkillCollection manifest dev-skills v0.1.0 with one Git-sourced skill and one OCI image skill (document-summarizer:1.0.0-testing).

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as collection install
    participant Resolver as Collection Resolver
    participant Validator as Validator
    participant Git as Git Ops
    participant OCI as OCI Client
    participant FS as Filesystem
    participant Prov as Provenance Writer

    User->>CLI: run collection install (file or Git URL)
    CLI->>Resolver: load & parse collection
    Resolver-->>CLI: collection data
    CLI->>Validator: validate collection schema
    Validator-->>CLI: validation result
    CLI->>FS: ensure destination directory
    FS-->>CLI: ready

    loop per skill
        alt image (OCI)
            CLI->>OCI: pull image (if remote)
            OCI-->>CLI: image data/digest
            CLI->>FS: unpack image to dest
            CLI->>Prov: WriteProvenance(digest)
            Prov-->>CLI: success / warn
        else source (Git)
            CLI->>Git: LsRemote(cloneURL, ref)
            Git-->>CLI: commit SHA
            CLI->>Git: clone/fetch at SHA (sparse unless disabled)
            Git-->>CLI: repo checked out
            CLI->>OCI: build artifact from repo
            OCI-->>CLI: built artifact
            CLI->>FS: unpack artifact to dest
            CLI->>Prov: WriteProvenance(commit SHA)
            Prov-->>CLI: success / warn
        end
    end

    CLI-->>User: complete (or error if failures)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically describes the main change: adding support for Git source URLs in collection YAML.
Linked Issues check ✅ Passed The pull request successfully implements all key objectives from issue #35: source field support, mutual exclusivity with image, collection install command, Git clone-build-install flow, skip logic via git ls-remote, and provenance recording.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #35 objectives. The refactoring of WriteProvenance and NewSkillCardFromRef to exported functions, and DisableSparse addition to CloneOptions, are necessary supporting changes for the collection install feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/collection-install-git-sources

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 51 minutes and 13 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@pavelanni
pavelanni marked this pull request as ready for review May 1, 2026 19:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/cli/install.go (1)

178-200: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Derive Metadata.Namespace from the repository path, not the registry host.

Using the first / truncates multi-segment refs, so ghcr.io/org/team/skill:1.2.3 is serialized with Namespace: ghcr.io instead of ghcr.io/org/team. That writes incorrect provenance/metadata for any nested repo path.

Proposed fix
-	namespace := "unknown"
-	if idx := strings.Index(ref, "/"); idx >= 0 {
-		namespace = ref[:idx]
-	}
+	namespace := "unknown"
+	if idx := strings.LastIndex(ref, "/"); idx >= 0 {
+		namespace = ref[:idx]
+	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/cli/install.go` around lines 178 - 200, NewSkillCardFromRef
currently derives Metadata.Namespace by taking everything before the first '/'
which yields only the registry host; change it to derive the repository path by
using the last '/' in the ref so nested repo paths are preserved (e.g.
"ghcr.io/org/team" for "ghcr.io/org/team/skill:1.2.3"). In NewSkillCardFromRef,
replace the first-slash logic with strings.LastIndex(ref, "/") and set namespace
= ref[:lastSlash] when lastSlash >= 0 (leave "unknown" otherwise); keep
tagFromRef/version handling and the call sites intact so only namespace
serialization changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/cli/collection.go`:
- Around line 321-341: The skip-on-up-to-date logic in installFromSource
currently only runs when skillLabel(s) is non-empty, so source-based skills
without a name never hit the git ls-remote fast path; change the gate to use a
resolved identity instead of the optional collection label: in
installFromSource, remove the label != "" condition and compute a stable key
(e.g., resolvedID := skillLabel(s); if resolvedID == "" { resolvedID =
resolveSkillIdentityFromSource(src) } ) then call readInstalledCommit(destDir,
resolvedID) and proceed with the existing ref/ls-remote comparison (using
source.ParseGitURL and source.LsRemote) so unnamed source entries can be skipped
correctly; alternatively enforce a name in validation if you prefer, but
implement the resolvedID approach in installFromSource to fix the current
behavior.

In `@pkg/collection/collection.go`:
- Around line 66-79: The validation currently allows entries with s.Source set
but no s.Name which later causes invalid Kube/Podman generation; update the
validation block around s.Image/s.Source/s.Name (the switch and subsequent
checks that append to errs and update seen) to explicitly reject source-only
entries by adding a case for s.Source != "" && s.Name == "" with an error like
"skills[%d].name is required for source entries", and ensure duplicate-name
checks (seen map) still run only when s.Name != ""; alternatively, if you prefer
generator-side enforcement, modify the generator functions that render
Kube/Podman output to return an error when encountering a skill with s.Source
set and s.Name empty so generation fails fast.

In `@pkg/source/lsremote_test.go`:
- Around line 8-35: The tests TestLsRemoteReturnsCommitSHA and
TestLsRemoteBadRef call LsRemote (and CheckGit) against GitHub and must be
converted to gated integration tests and use a timeout: mark or move these tests
so they're only run for integration (e.g., add an integration build tag or
rename to *_integration_test.go and/or check testing.Short() and call t.Skip),
and wrap their context.Background() usage with context.WithTimeout to a
reasonable duration (e.g., 10s) and defer cancel(); keep references to CheckGit
and LsRemote unchanged so the same helpers are used, and ensure the skip/gate
prevents CI flakiness while the timeout prevents indefinite hangs.

In `@pkg/source/lsremote.go`:
- Around line 24-37: The error messages currently interpolate the raw cloneURL
(variable cloneURL) which can leak credentials; before constructing the
fmt.Errorf messages (the ones that include cloneURL alongside ref and
sanitizeGitOutput), parse cloneURL with net/url (e.g., url.Parse), strip or zero
out the User info, and use the resulting sanitized string (e.g., safeCloneURL)
in the three error returns instead of cloneURL so userinfo is never included in
logs or errors.

---

Outside diff comments:
In `@internal/cli/install.go`:
- Around line 178-200: NewSkillCardFromRef currently derives Metadata.Namespace
by taking everything before the first '/' which yields only the registry host;
change it to derive the repository path by using the last '/' in the ref so
nested repo paths are preserved (e.g. "ghcr.io/org/team" for
"ghcr.io/org/team/skill:1.2.3"). In NewSkillCardFromRef, replace the first-slash
logic with strings.LastIndex(ref, "/") and set namespace = ref[:lastSlash] when
lastSlash >= 0 (leave "unknown" otherwise); keep tagFromRef/version handling and
the call sites intact so only namespace serialization changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 9d8f6d24-83e2-437d-a6a2-95d0fcd1c827

📥 Commits

Reviewing files that changed from the base of the PR and between 3c9c32f and 48e1011.

📒 Files selected for processing (10)
  • examples/dev-collection.yaml
  • internal/cli/collection.go
  • internal/cli/collection_install_test.go
  • internal/cli/install.go
  • internal/cli/install_test.go
  • internal/cli/upgrade.go
  • pkg/collection/collection.go
  • pkg/collection/collection_test.go
  • pkg/source/lsremote.go
  • pkg/source/lsremote_test.go

Comment thread internal/cli/collection.go Resolved
Comment on lines +66 to +79
switch {
case s.Image != "" && s.Source != "":
errs = append(errs, fmt.Sprintf("skills[%d]: image and source are mutually exclusive", i))
case s.Image == "" && s.Source == "":
errs = append(errs, fmt.Sprintf("skills[%d]: image or source is required", i))
case s.Image != "" && s.Name == "":
errs = append(errs, fmt.Sprintf("skills[%d].name is required for image entries", i))
}
if s.Name != "" && seen[s.Name] {
errs = append(errs, fmt.Sprintf("duplicate skill name %q", s.Name))
}
seen[s.Name] = true
if s.Name != "" {
seen[s.Name] = true
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Validation now permits data that generator paths cannot safely render.

By allowing source-only entries without name (Line 69 onward), you can pass validation but still generate invalid Kube/Podman output later in this file (empty names/image references). Please add explicit guardrails: either enforce image+name for generation workflows or make generator functions return errors on unsupported source entries.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/collection/collection.go` around lines 66 - 79, The validation currently
allows entries with s.Source set but no s.Name which later causes invalid
Kube/Podman generation; update the validation block around
s.Image/s.Source/s.Name (the switch and subsequent checks that append to errs
and update seen) to explicitly reject source-only entries by adding a case for
s.Source != "" && s.Name == "" with an error like "skills[%d].name is required
for source entries", and ensure duplicate-name checks (seen map) still run only
when s.Name != ""; alternatively, if you prefer generator-side enforcement,
modify the generator functions that render Kube/Podman output to return an error
when encountering a skill with s.Source set and s.Name empty so generation fails
fast.

Comment thread pkg/source/lsremote_test.go Resolved
Comment thread pkg/source/lsremote.go Resolved
pavelanni added 2 commits May 1, 2026 16:49
- Derive skip-check identity from source URL subpath when name
  is omitted, so unnamed source entries hit the ls-remote fast path
- Sanitize credentials from URLs in LsRemote error messages
- Gate LsRemote tests with testing.Short() and add context timeouts

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
…en symlinks

When a repository uses symlinks that point outside the sparse
checkout scope, Discover() cannot find SKILL.md files. Detect
this by retrying with DisableSparse when Discover fails after
a sparse checkout.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/source/lsremote.go`:
- Around line 35-43: The code currently grabs the first line's SHA
(firstLine/fields) which returns the tag object ID for annotated tags; instead
iterate over the output lines and if any line's refname field ends with "^{ }"
(the peeled tag ref, typically "refs/tags/...^{}") return that line's SHA
(fields[0]); otherwise fall back to returning the first line's SHA. Update the
parsing in lsremote.go (the block using firstLine and fields) to prefer the
peeled-ref line when present before returning the SHA.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 3c8690ee-0cd7-4313-9429-cd05637b9214

📥 Commits

Reviewing files that changed from the base of the PR and between 48e1011 and a1ce907.

📒 Files selected for processing (5)
  • internal/cli/collection.go
  • pkg/source/clone.go
  • pkg/source/lsremote.go
  • pkg/source/lsremote_test.go
  • pkg/source/source.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/source/lsremote_test.go
  • internal/cli/collection.go

Comment thread pkg/source/lsremote.go
Comment on lines +35 to +43
// Output format: "<sha>\t<refname>\n" — may have multiple lines.
// Take the first line's SHA.
firstLine := strings.SplitN(output, "\n", 2)[0]
fields := strings.Fields(firstLine)
if len(fields) < 1 {
return "", fmt.Errorf("unexpected ls-remote output for %s %s", safeURL, ref)
}

return fields[0], nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n pkg/source/lsremote.go

Repository: redhat-et/skillimage

Length of output: 1695


🏁 Script executed:

rg "LsRemote" --type go

Repository: redhat-et/skillimage

Length of output: 788


🏁 Script executed:

rg -B 5 -A 10 "remoteSHA, lsErr := source.LsRemote" internal/cli/collection.go

Repository: redhat-et/skillimage

Length of output: 458


🏁 Script executed:

cat -n pkg/source/lsremote_test.go

Repository: redhat-et/skillimage

Length of output: 1483


🏁 Script executed:

rg -B 3 -A 3 "commitSHAPattern" pkg/source/

Repository: redhat-et/skillimage

Length of output: 1032


🏁 Script executed:

rg -B 5 -A 15 "installedSHA" internal/cli/collection.go | head -50

Repository: redhat-et/skillimage

Length of output: 789


🏁 Script executed:

rg -B 5 -A 10 "func readInstalledCommit" internal/cli/

Repository: redhat-et/skillimage

Length of output: 809


🏁 Script executed:

rg -B 2 -A 8 "readInstalledCommit" internal/cli/collection.go | tail -30

Repository: redhat-et/skillimage

Length of output: 829


🏁 Script executed:

rg -A 15 "func readInstalledCommit" internal/cli/collection.go

Repository: redhat-et/skillimage

Length of output: 418


🏁 Script executed:

cd /tmp && git clone --depth 1 https://github.com/octocat/Hello-World.git test-repo 2>/dev/null && cd test-repo && echo "=== Branches ===" && git ls-remote origin master && echo "=== Tags ===" && git ls-remote origin v0.0.1 2>/dev/null || echo "Tag not found" && echo "=== All refs ===" && git ls-remote origin | head -20

Repository: redhat-et/skillimage

Length of output: 1372


🏁 Script executed:

cd /tmp && rm -rf test-repo && git clone --depth 1 https://github.com/git/git.git test-repo 2>&1 | grep -i clone && cd test-repo && echo "=== Querying for a lightweight ref ===" && git ls-remote origin refs/tags/v2.40.0 2>/dev/null || git ls-remote origin refs/tags/v2.25.0 2>/dev/null || (echo "Trying v2.0.0:" && git ls-remote origin refs/tags/v2.0.0)

Repository: redhat-et/skillimage

Length of output: 280


🌐 Web query:

git ls-remote annotated tag output peeled ^{} format

💡 Result:

The git ls-remote command outputs references from a remote repository in the format TAB LF. For annotated tags (created with git tag -a), it shows two lines per tag unless --refs is used: one for the tag ref pointing to the annotated tag object, and another for ^{} pointing to the peeled object (typically a commit) that the tag references. The ^{} suffix dereferences the tag recursively to a non-tag object. Example output: d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0 73876f4861cd3d187a4682290ab75c9dccadbc56 refs/tags/v2.40.0^{} Lightweight tags (created with plain git tag) show only one line. Use --refs to show only the tag refs without peeled lines, or --tags to list only tags.

Citations:


🏁 Script executed:

rg -i "annotated" --type go pkg/ internal/

Repository: redhat-et/skillimage

Length of output: 200


🏁 Script executed:

rg "git tag" --type go pkg/ internal/ || echo "No git tag commands in code"

Repository: redhat-et/skillimage

Length of output: 92


🏁 Script executed:

rg -i "tag" pkg/source/clone.go | head -20

Repository: redhat-et/skillimage

Length of output: 46


🏁 Script executed:

find . -name "*test*" -type f -exec grep -l "tag" {} \; | head -10

Repository: redhat-et/skillimage

Length of output: 228


Handle peeled tag output before returning the SHA.

git ls-remote returns two lines for annotated tags: the tag object ID on the first line, and the peeled commit ID on the second line with a ^{} suffix. The current code returns the tag object ID, which breaks the skip logic in collection.go that compares against stored commit SHAs—for annotated tags, tag object ID ≠ commit ID, so the comparison fails and unnecessary clones occur.

Suggested fix
-	// Output format: "<sha>\t<refname>\n" — may have multiple lines.
-	// Take the first line's SHA.
-	firstLine := strings.SplitN(output, "\n", 2)[0]
-	fields := strings.Fields(firstLine)
-	if len(fields) < 1 {
-		return "", fmt.Errorf("unexpected ls-remote output for %s %s", safeURL, ref)
-	}
-
-	return fields[0], nil
+	var fallbackSHA string
+	for _, line := range strings.Split(output, "\n") {
+		fields := strings.Fields(line)
+		if len(fields) < 2 {
+			continue
+		}
+		if strings.HasSuffix(fields[1], "^{}") {
+			return fields[0], nil
+		}
+		if fallbackSHA == "" {
+			fallbackSHA = fields[0]
+		}
+	}
+	if fallbackSHA == "" {
+		return "", fmt.Errorf("unexpected ls-remote output for %s %s", safeURL, ref)
+	}
+	return fallbackSHA, nil
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/source/lsremote.go` around lines 35 - 43, The code currently grabs the
first line's SHA (firstLine/fields) which returns the tag object ID for
annotated tags; instead iterate over the output lines and if any line's refname
field ends with "^{ }" (the peeled tag ref, typically "refs/tags/...^{}") return
that line's SHA (fields[0]); otherwise fall back to returning the first line's
SHA. Update the parsing in lsremote.go (the block using firstLine and fields) to
prefer the peeled-ref line when present before returning the SHA.

Build() tags images as <version>-draft by default, but
installFromSource used bare <version> for the unpack ref.
Use lifecycle.TagForState to construct the correct tag.

Refs: #35

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@pavelanni
pavelanni merged commit e133701 into main May 1, 2026
5 checks passed
@pavelanni
pavelanni deleted the feature/collection-install-git-sources branch May 1, 2026 21: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.

feat: support Git source URLs in collection YAML for development workflow

1 participant