Repository navigation
feat(gitter): add POST /commit-pack endpoint for shallow commit archives - #6431
Draft
another-rex wants to merge 3 commits into
Draft
another-rex wants to merge 3 commits into
another-rex wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6431 +/- ##
==========================================
+ Coverage 55.57% 55.89% +0.32%
==========================================
Files 222 222
Lines 22919 23195 +276
==========================================
+ Hits 12737 12965 +228
- Misses 10179 10227 +48
Partials 3 3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
another-rex
marked this pull request as ready for review
November 24, 2026 02:18
another-rex
marked this pull request as draft
November 24, 2026 02:55
…ess PR review findings
This branch has not been deployed
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.
Overview
(AI-assisted PR)
Split out from #6403 for easier review.
Adds a
POST /commit-packendpoint togitter(and correspondingGetCommitPackmethod ongo/internal/gitter.Client) that builds and returns a minimal, standalone shallow bare Git repository archive (.tar.zst) containing only the requested commit(s), their immediate parent(s), and the trees/blobs touched by each commit diff.This enables downstream consumers (such as the upcoming Vanir sandbox in #6403) to extract commit diffs completely offline from
gitter's cached repositories without transferring entire repository histories.Details
go/internal/gitter/):CommitPackRequest(url,commits,ref_id) torepository.protoand regeneratedrepository.pb.go.GetCommitPack,ErrPackTooLarge(413 Request Entity Too Large), and sharedMaxCommitPackBytes(44 MiB) togo/internal/gitter.200 OK, non-empty body,Content-Lengthfail-fast, andio.LimitReaderbounds inGetCommitPack; deduplicated error-detail wrapping inhttpClient.do.go/cmd/gitter/):POST /commit-pack(commitPackHandler) validatingurlviaprepareURL, capping requests at1..64validated hex commit hashes, deduplicating hashes, bypassing204 No Contententries cached by/tags, and settingContent-Lengthon responses.RLockfreshness fast path inrefreshReposo concurrent/commit-packreaders on recently synced repos don't serialize behindrepoLock.Lock().resolveValidCommits(git cat-file --batch-check) to verify requested hashes are exact commit OIDs (rejecting missing commits, prefix abbreviations, and non-commit objects like annotated tags/blobs/trees).CreateCommitPack+materializeDiffBlobs:repoLock.RLock()only during local reads without mutating the cached repo's.git/configby configuringremote.origin.uploadpackon the temporary bare clone (supporting--object-format=sha256for 64-char hashes).--filter=blob:none --depth=2 --no-tags, collects all touched blob OIDs across normal, root, and merge commits in one batchedgit diff-tree --stdin -r --raw --no-renames --no-commit-id -m --first-parent --rootpass, and transfers them in a singlegit pack-objects | git index-pack --stdin --fix-thinstream.remote.origin, enablesuploadpack.allowFilter/uploadpack.allowAnySHA1InWant, dropshooks/andFETCH_HEAD, and compresses withtar --zstd(matchingArchiveRepo, capped atMaxCommitPackBytes).ForceUpdate: true(subject to a 1-minute cooldown) and partial-pack support when a requested commit is missing in the cached repo.GIT_TERMINAL_PROMPT=0intoprepareCmdfor allgitinvocations and removed the redundantenvparameter fromprepareCmd/runCmd.Testing
go/cmd/gitter/commit_pack_test.gocovering validation (400/413), missing commits & annotated tags (404),invalidRepoCache(204bypass vs404), cooldown suppression vsForceUpdaterefresh + partial pack extraction, standalone normal + merge + root + multi-commit packs after deleting source & cache repos (verifying unrelated 2 MiB blob exclusion and absence ofhooks/FETCH_HEAD/remote.origin), and oversized archive413.TestGetCommitPackingo/internal/gitter/http_test.gocovering200,400,403,404,413with body detail,500,204, empty200, and oversized chunked200responses.cd go && go test -v -race -count=1 ./internal/gitter/...— PASScd go && go test -v -race -count=1 ./cmd/gitter -run TestCommitPackHandler— PASS (including isolated-run TestCommitPackHandler/cooldown)cd go && go build ./...— PASS./tools/lint_and_format.sh— PASS (0 issues)agy