Add optional shallow submodule checkouts - #12
Merged
andrew merged 1 commit intoAug 24, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in path to shallow-initialize and update Git submodules (recursively, depth 1) as part of the existing “clone-or-fetch + reset” workflow, without changing default behavior for existing callers. It introduces a new options-based API surface and extends the cache feature so cached checkouts can include best-effort submodule contents.
Changes:
- Add
EnsureWithOptions+EnsureOptions(backward-compatible with existingEnsure), with opt-inRecurseSubmodules. - Perform best-effort
git submodule update --init --recursive --depth 1after both initial clone and later fetch/reset updates (while still propagating context cancellation). - Add
Cache.RecurseSubmodulesand tests/docs to support copying shallow submodule contents into cached destinations.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents EnsureWithOptions submodule opt-in behavior and the new cache flag. |
| ensure.go | Adds options-based API and implements best-effort recursive shallow submodule updates. |
| ensure_test.go | Adds integration + unit tests for opt-in submodule behavior, best-effort failures, and cancellation. |
| doc.go | Updates package docs to mention optional shallow submodules. |
| cache.go | Adds Cache.RecurseSubmodules and wires it into cache preparation via EnsureWithOptions. |
| cache_test.go | Adds coverage for cache copies including submodule contents. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
andrew
approved these changes
Aug 24, 2026
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.
Closes #11
Summary
EnsureWithOptionsAPI with opt-in recursive submodule supportCache.RecurseSubmodulesso cached checkouts can include shallow submodule contentsTesting
go build -v ./...go vet ./...go test -v -race ./...go test -v -race ./...in thegogitmodulegogit0 issues)gofmtandgit diff --checkIncludes integration coverage for opt-in behavior, shallow initialization, submodule updates, cache copies, best-effort failures and context cancellation.