Conversation
commit: |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the backend’s GitHub integration to reduce memory/bandwidth pressure during uploads by separating blob creation from tree/commit creation (REST Git endpoints + streaming), and introduces a new “git smart protocol” implementation (upload-pack / receive-pack) that is now wired in for write/getBlobs while keeping history APIs on the existing implementation.
Changes:
- Switch
GithubApi.writeto REST Git data endpoints (blobs/trees/commits/refs) and stream large blob uploads in chunks with configurable concurrency and size limits. - Add a new
GitSmartApiwith protocol helpers (pkt-line, sideband parsing), pack (de)serialization, and commit object serialization. - Update backend wiring to compose implementations so
write/getBlobsgo through the smart implementation whilerevisions/revisionDataremain on the existing GitHub implementation; add extensive tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/backend/api/GithubApi.ts | Implements REST-based commit writes and streamed/chunked blob uploads with concurrency/limits. |
| src/backend/api/GithubApi.test.ts | Adds coverage for REST write flow, streaming blob uploads, size limits, and race handling. |
| src/backend/api/GitSmartApi.ts | Implements smart-protocol based write (receive-pack) and getBlobs (upload-pack). |
| src/backend/api/GitSmartApi.test.ts | Adds end-to-end style protocol mocks to validate receive-pack/upload-pack behavior. |
| src/backend/api/gitSmart/GitSmartProtocol.ts | Adds pkt-line encoding/decoding, advertisement parsing, and request builders. |
| src/backend/api/gitSmart/GitSmartProtocol.test.ts | Adds unit tests for protocol parsing and request formatting. |
| src/backend/api/gitSmart/GitSmartPack.ts | Adds pack creation and parsing (including delta handling). |
| src/backend/api/gitSmart/GitSmartPack.test.ts | Adds pack roundtrip and ref-delta parsing tests. |
| src/backend/api/gitSmart/GitSmartObjects.ts | Adds commit object serialization + hashing helpers. |
| src/backend/api/gitSmart/GitSmartObjects.test.ts | Adds deterministic serialization/hash tests for commit objects. |
| src/backend/api/CreateBackend.ts | Wires both GithubApi + GitSmartApi into the composed backend remote. |
| src/backend/api/CreateBackend.test.ts | Verifies routing behavior of the composed remote implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| input.capabilities.has('side-band-64k') ? 'side-band-64k' : undefined, | ||
| input.capabilities.has('ofs-delta') ? 'ofs-delta' : undefined | ||
| ].filter(Boolean) | ||
| const command = `${input.oldSha} ${input.newSha} ${input.ref}\0${requestedCaps.join(' ')}\n` |
| const unique = Array.from(new Set(shas)) | ||
| const adv = await this.#advertise('git-upload-pack') | ||
| if (!adv.capabilities.has('allow-reachable-sha1-in-want')) { | ||
| yield* super.getBlobs(unique) |
| await end | ||
| return { | ||
| data: concatUint8Arrays(chunks), | ||
| bytesConsumed: inflater.bytesWritten |
Comment on lines
+28
to
+36
| const entries = await Promise.all( | ||
| objects.map(async object => { | ||
| const type = packTypeCode(object.type) | ||
| return concatUint8Arrays([ | ||
| encodePackObjectHeader(type, object.data.length), | ||
| await deflate(object.data) | ||
| ]) | ||
| }) | ||
| ) |
| const requestedCaps = [ | ||
| capabilities.has('side-band-64k') ? 'side-band-64k' : undefined, | ||
| capabilities.has('ofs-delta') ? 'ofs-delta' : undefined, | ||
| 'no-progress' |
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.
Handle blob uploads separately so we run into memory and bandwidth limits less fast than before