dgit - about
git.littledivy.com : dgit
a durable forge for the git dscm, on Cloudflare
aboutsummaryrefslogtreecommitdiffstatsmain
dgit
Durable git .
dgit is a git server for Cloudflare Workers and for your own machines<br>with celld. Each repository is a Durable Object: a<br>small server with a name and a private SQLite database that holds the<br>repository's objects and refs, speaks the git smart HTTP protocol to a<br>stock git client, and renders a cgit-style web interface. There is no<br>origin server, no filesystem, and no GitHub in the critical path. A<br>repository nobody touches costs almost nothing, and applications shard<br>by construction: one hot repository cannot slow another. Reads are<br>public; pushes authenticate; pushing to a name that does not exist<br>creates the repository.
How it works
dgit implements git in TypeScript: pkt-line framing, packfile parsing<br>with ofs- and ref-delta resolution, pack generation over a streaming<br>SHA-1, commit/tree/tag codecs, and a Myers diff. The one dependency is<br>pako, for zlib.
A push streams into the repository's cell and is stored as the packfile<br>the client sent; an index maps each object id to its pack, offset, and<br>delta base, so the client's compression is preserved rather than<br>re-derived. A clone walks the closure of the requested refs and copies<br>the stored compressed bytes verbatim into the outgoing pack. Fetch<br>negotiation excludes the closure of the client's haves, cut correctly<br>at shallow boundaries, so an incremental fetch downloads only what is<br>missing. Shallow clones (--depth, deepening, --unshallow), thin<br>packs, side-band progress, forced updates, and ref deletion behave as<br>they do against any git server.
The web interface is the cgit surface: summary, refs, log with search<br>and per-path history, tree, blob with syntax highlighting, blame,<br>commit and arbitrary-range diffs, format-patch output that applies<br>cleanly with git am, tar.gz and zip snapshots of any ref, about pages<br>rendered from the README, atom feeds, and commit-activity statistics.<br>Repositories carry a description, an owner, a section on the index<br>page, and a private flag that hides them and gates every read behind<br>the push token.
Deploy to Cloudflare
npm install<br>npx wrangler deploy<br>npx wrangler secret put GIT_TOKEN # the push password<br>Then push anything:
git remote add origin https:///myrepo.git<br>git push -u origin main<br>A Workers request is bounded at 128MB of memory and five minutes of<br>CPU, so a very large history lands as a series of smaller pushes rather<br>than one; day-to-day pushes, clones, and fetches fit comfortably. A<br>full-history clone of a repository with millions of objects can exceed<br>the CPU bound — shallow and incremental fetches of the same repository<br>are fine.
Self-host on celld
celld runs the same Worker against a bucket you own, with none of the<br>managed platform's request bounds. Set a real GIT_TOKEN var in<br>wrangler.celld.jsonc first:
celld deploy wrangler.celld.jsonc --bucket s3://my-cells --endpoint https://...<br>CELLD_V8_HEAP_LIMIT_MB=4096 CELLD_LTX_DURABILITY_TIMEOUT_SECS=180 \<br>celld --bucket s3://my-cells --endpoint https://... \<br>--listen 0.0.0.0:8080 --internal-listen 10.0.0.1:8081 --advertise 10.0.0.1:8081<br>Each repository's SQLite database replicates to the bucket; nodes are<br>disposable, and a killed node's repositories come back bit-identical.<br>The heap and durability-deadline variables give large single-cell<br>ingests the room the defaults do not.
Operate
curl -X PUT -u x:$GIT_TOKEN -d '{"description":"...","section":"tools","private":false}' \<br>https:///myrepo/config # describe and place a repository<br>curl -X POST -u x:$GIT_TOKEN https:///myrepo/gc # prune unreachable objects<br>curl -X DELETE -u x:$GIT_TOKEN https:///myrepo # delete a repository<br>Garbage collection also runs by itself, from a Durable Object alarm,<br>after a forced update or a ref deletion. GIT_TOKENS holds additional<br>comma-separated tokens; MAX_PUSH_MB caps a single push.
Contributions
Pull requests are disabled. Send a git format-patch attachment to me@littledivy.com.
generated by dgit 0.2 (cgit on Cloudflare Workers / celld)