Skip to content

Expose deterministic submodule metadata - #14

Merged
andrew merged 3 commits into
mainfrom
expose-submodule-metadata
Aug 25, 2026
Merged

Expose deterministic submodule metadata#14
andrew merged 3 commits into
mainfrom
expose-submodule-metadata

Conversation

@andrew

@andrew andrew commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Add a Submodules query for prepared checkouts. Each record reports the checkout-relative path, resolved credential-free URL, exact gitlink commit, pinned PURL, initialization status, and a safe error for unavailable submodules.

Read declarations from the committed .gitmodules blob and recurse through initialized submodules. Use github.com/git-pkgs/purl for pinned GitHub and generic VCS identities, and document the query after Cache.Prepare.

Copilot AI 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.

Pull request overview

This PR adds a new Submodules query to expose deterministic, credential-free metadata about declared submodules in a prepared checkout, including resolved URLs and pinned PURLs, while tolerating unavailable submodules.

Changes:

  • Introduces Submodules(ctx, dir) and supporting helpers to read submodule declarations from the committed .gitmodules blob, compute gitlink commits, and derive pinned PURLs.
  • Adds tests covering initialized nested submodules, unavailable submodules without credential leakage, and repositories with no submodules.
  • Documents how to call Submodules after Cache.Prepare, and adds the github.com/git-pkgs/purl dependency.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
submodule.go Implements the submodule discovery, URL resolution/redaction, gitlink commit extraction, and PURL generation.
submodule_test.go Adds coverage for initialized nested submodules and unavailable submodules with credential redaction.
README.md Documents using Submodules on a prepared checkout.
go.mod Adds the purl dependency (and resulting indirect deps).
go.sum Records checksums for newly added dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread submodule.go Outdated
Comment on lines +216 to +218
if err != nil {
return "", err
}
Comment thread submodule_test.go
Comment on lines +189 to +191
func TestSubmodulesReturnsEmptyForCheckoutWithoutSubmodules(t *testing.T) {
repository := newTestRepository(t, "file.txt")
modules, err := Submodules(context.Background(), repository.dir)
@andrew
andrew merged commit 888baca into main Aug 25, 2026
2 checks passed
@andrew
andrew deleted the expose-submodule-metadata branch August 25, 2026 14:47
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.

2 participants