Artifactspublic-v0

ply

main
ply4 git calls428 ms39 KiB1 cachedprotocol v2
36 lines2.8 KiBRaw

examples

Three CLI scripts that use ply as the git client from a machine with Node and no git binary. Each is a thin wrapper over a first-class API; test/examples.test.js runs all three, as a user would, against git http-backend with the client's PATH holding only node.

sh
npm install                   # once, in a clone: builds dist/, which the examples import as `ply` (no build, no examples)
export PLY_TOKEN=…            # Basic auth (user PLY_USER, default x-access-token); or PLY_BEARER for Bearer
node examples/push-tree.mjs ./site https://host/repo.git --ref main --message "deploy"
node examples/checkout-tree.mjs https://host/repo.git ./out --ref main
node examples/push-repo.mjs ./repo https://host/repo.git main --tags

Credentials come from the environment only, never argv (argv shows up in ps and shell history). Author is GIT_AUTHOR_NAME / GIT_AUTHOR_EMAIL.

  • push-tree.mjs <dir> <remote> [--ref main] [--message …] — pushDir (ply/tree-node): the directory as one commit. Creates the ref with the zero old-oid, or updates it with its current head as the CAS. Prints the old → new commit, the objects sent and the pack bytes. The push is thin: whatever the previous commit already has is left out, so a repeat with one file changed sends that blob, the trees on its path and the commit; a repeat with nothing changed is a noop and sends nothing. .git is skipped; .gitignore is not read (give pushDir a filter for that).

  • checkout-tree.mjs <remote> <dir> [--ref main] — checkoutDir (ply/checkout-node): a ref (default HEAD) into an absent or empty directory, laid out as git clone lays it out (100755 executable, 120000 a symlink, a submodule an empty directory), every blob hash-checked as it streams. Prints the commit and the files, bytes and symlinks written. Three requests whatever the file count: ls-refs, a blob:none tree fetch, one fetch for the blobs.

  • push-repo.mjs <repo-dir> <remote> [refspec …] [--all] [--tags] [--force] [--dry-run] [--thin] — pushRepo (ply/repo-node): git push of a local repository, history included, with ply reading .git itself. Refspecs are git's (main, src:dst, +src:dst, :dst); none pushes the current branch. Prints each ref's old → new (or Everything up-to-date, with nothing sent) and the objects, deltas and pack bytes. A non-fast-forward is refused before anything is sent (not_fast_forward) unless forced.

Measured by test/examples.test.js (9 files, 6 trees, two symlinks, an exec bit): create sends 16 objects / 4683 pack bytes; a one-file change four directories deep sends 6 objects (1 blob, 4 trees, the commit) / 488 bytes; an unchanged tree is a noop. The checkout is byte-identical to the source with modes, and so is git clone of the remote.

1# examples
3Three CLI scripts that use ply as the git client from a machine with Node and no `git` binary. Each is a thin wrapper over
4a first-class API; `test/examples.test.js` runs all three, as a user would, against `git http-backend` with the client's
5`PATH` holding only `node`.
7```sh
8npm install # once, in a clone: builds dist/, which the examples import as `ply` (no build, no examples)
9export PLY_TOKEN=… # Basic auth (user PLY_USER, default x-access-token); or PLY_BEARER for Bearer
10node examples/push-tree.mjs ./site https://host/repo.git --ref main --message "deploy"
11node examples/checkout-tree.mjs https://host/repo.git ./out --ref main
12node examples/push-repo.mjs ./repo https://host/repo.git main --tags
13```
15Credentials come from the environment only, never argv (argv shows up in `ps` and shell history). Author is
16`GIT_AUTHOR_NAME` / `GIT_AUTHOR_EMAIL`.
18- `push-tree.mjs <dir> <remote> [--ref main] [--message …]` — `pushDir` (`ply/tree-node`): the directory as one commit.
19 Creates the ref with the zero old-oid, or updates it with its current head as the CAS. Prints the old → new commit,
20 the objects sent and the pack bytes. The push is thin: whatever the previous commit already has is left out, so a
21 repeat with one file changed sends that blob, the trees on its path and the commit; a repeat with nothing changed is
22 a `noop` and sends nothing. `.git` is skipped; `.gitignore` is not read (give `pushDir` a `filter` for that).
23- `checkout-tree.mjs <remote> <dir> [--ref main]` — `checkoutDir` (`ply/checkout-node`): a ref (default `HEAD`) into an
24 absent or empty directory, laid out as `git clone` lays it out (`100755` executable, `120000` a symlink, a submodule
25 an empty directory), every blob hash-checked as it streams. Prints the commit and the files, bytes and symlinks
26 written. Three requests whatever the file count: ls-refs, a `blob:none` tree fetch, one fetch for the blobs.
28- `push-repo.mjs <repo-dir> <remote> [refspec …] [--all] [--tags] [--force] [--dry-run] [--thin]` — `pushRepo`
29 (`ply/repo-node`): `git push` of a local repository, history included, with ply reading `.git` itself. Refspecs are
30 git's (`main`, `src:dst`, `+src:dst`, `:dst`); none pushes the current branch. Prints each ref's old → new (or
31 `Everything up-to-date`, with nothing sent) and the objects, deltas and pack bytes. A non-fast-forward is refused
32 before anything is sent (`not_fast_forward`) unless forced.
34Measured by `test/examples.test.js` (9 files, 6 trees, two symlinks, an exec bit): create sends 16 objects / 4683 pack
35bytes; a one-file change four directories deep sends 6 objects (1 blob, 4 trees, the commit) / 488 bytes; an unchanged
36tree is a `noop`. The checkout is byte-identical to the source with modes, and so is `git clone` of the remote.
Diagnostics4 git calls · 428 ms
CallStatusSizeTime0428 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200145 B2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=145
git.response.cache=UPDATING
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=145
git.pkt.payload.max=76
git.ls_refs.count=2
git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020038 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=38434
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=6
git.pkt.data=4
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=38434
git.pkt.payload.max=38339
git.sideband.band1.bytes=38338
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=63
git.pack.bytes=38338
git.pack.ofs_delta=0
git.pack.ref_delta=8
git.pack.chain.max=8
git.pack.trailer=0bc36ab7adf82d3109177f11f1ea93f1ce071f77
git.pack.full=55
Open pack map
fetch2001.4 KiB423 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=423
git.response.bytes=1477
git.response.cache=MISS
git.response.duration_ms=423
git.fetch.wants=0be9b92568f632fb8568b9aaba9f8f56d771f118
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1477
git.pkt.payload.max=1456
git.sideband.band1.bytes=1455
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply.git
Ref
refs/heads/main
Commit
19912563f540228593df0c489082e5e2508e21e4
cf-ray
a5e2bc5aab23cfc3
Request
182bc8b2…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format