Expose deterministic submodule metadata - #14
Merged
Conversation
There was a problem hiding this comment.
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.gitmodulesblob, 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
SubmodulesafterCache.Prepare, and adds thegithub.com/git-pkgs/purldependency.
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 on lines
+216
to
+218
| if err != nil { | ||
| return "", err | ||
| } |
Comment on lines
+189
to
+191
| func TestSubmodulesReturnsEmptyForCheckoutWithoutSubmodules(t *testing.T) { | ||
| repository := newTestRepository(t, "file.txt") | ||
| modules, err := Submodules(context.Background(), repository.dir) |
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.
Add a
Submodulesquery 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
.gitmodulesblob and recurse through initialized submodules. Usegithub.com/git-pkgs/purlfor pinned GitHub and generic VCS identities, and document the query afterCache.Prepare.