GitHubivarvong

ply

main
ply7 git calls32 ms25 KiB6 cachedprotocol v2
86 lines4.9 KiBRaw
1// Every public entry takes refs and paths as plain `string`: each checks them at run time (validateRef, validatePushRef,
2// validatePath → bad_request) and keeps the Refname / Path brands inside. readme.typetest.ts covers the README calls;
3// this file covers the rest. `tsc --noEmit` must pass.
4import { editFile, validateSpec } from '../../src/edit.js';
5import { commitChanges, type Change } from '../../src/changes.js';
6import { pushTree } from '../../src/tree.js';
7import { pushDir } from '../../src/tree-node.js';
8import { readFile, listTree, readCommit } from '../../src/read.js';
9import { readLog } from '../../src/log.js';
10import { checkoutTree } from '../../src/checkout.js';
11import { checkoutDir } from '../../src/checkout-node.js';
12import { mergeBranch, fastForward, deleteRef } from '../../src/merge.js';
13import { rebaseBranch, cherryPick, revertCommit, pickCommit } from '../../src/rebase.js';
14import { createBranch, deleteBranch, createTag } from '../../src/refops.js';
15import { GitHttp } from '../../src/client.js';
16import { push, type Command } from '../../src/push.js';
17import { Tracer } from '../../src/otel.js';
18import { DEFAULT_LIMITS } from '../../src/limits.js';
19import type { Transport } from '../../src/transport.js';
21declare const url: string;
22declare const ref: string;
23declare const path: string;
24declare const oid: string;
25declare const t: Transport;
26const tracer = new Tracer();
27const author = { name: 'a', email: 'a@x' };
29await editFile(url, { ref, base: ref, path, find: 'a', replace: 'b', author, message: 'm' }, { tracer });
30void validateSpec({ ref, path, find: 'a', replace: 'b', author, message: 'm' }, DEFAULT_LIMITS);
31const changes: Change[] = [
32 { kind: 'create', path, content: 'x' }, { kind: 'write', path, content: 'x', mode: '100755' },
33 { kind: 'edit', path, find: 'a', replace: 'b' }, { kind: 'delete', path }, { kind: 'rename', from: path, to: path },
34];
35await commitChanges(url, { ref, base: ref, changes, author, message: 'm' }, { tracer });
36await pushTree(url, { ref, base: ref, files: { [path]: 'x' }, author, message: 'm' }, { tracer });
37await pushDir(url, { dir: '.', ref, author, message: 'm' }, { tracer });
38await readFile(url, { ref, path }, { tracer });
39await listTree(url, { ref, path }, { tracer });
40await readCommit(url, { ref }, { tracer });
41await readLog(url, { ref, limit: 5 }, { tracer });
42await checkoutTree(url, { ref, path }, { tracer });
43await checkoutDir(url, { dir: './out', ref, path }, { tracer });
44await checkoutDir(url, { dir: './out' }, { tracer });
45await mergeBranch(url, { ref, from: ref, author }, { tracer });
46await rebaseBranch(url, { ref, onto: ref, committer: author }, { tracer });
47await cherryPick(url, { ref, commit: oid, committer: author }, { tracer });
48await revertCommit(url, { ref, commit: oid, committer: author }, { tracer });
49await pickCommit(url, { ref, commit: oid, committer: author, revert: true }, { tracer });
50await createBranch(url, { ref, from: ref }, { tracer, verify: true });
51await deleteBranch(url, { ref, expected: oid }, { tracer });
52await deleteBranch(url, { ref }, { tracer });
53await createTag(url, { name: ref, target: ref, message: 'm', tagger: author }, { tracer });
54await fastForward(t, { ref, from: oid, to: oid });
55await deleteRef(t, { ref, oid });
56const command: Command = { ref, oldOid: oid, newOid: oid };
57await push(t, { ref, oldOid: oid, newOid: oid, objects: [] });
58await push(t, { commands: [command] });
59const client = GitHttp.create(url);
60if (client.ok) await client.value.push({ ref, oldOid: oid, newOid: oid, objects: [], atomic: false });
62// HttpOptions in, HttpSettings out (#156): settings come only from parseHttpOptions
63import { parseHttpOptions, type HttpSettings } from '../../src/http.js';
64const settings = parseHttpOptions(url, { userAgent: 'x', limits: DEFAULT_LIMITS });
65if (settings.ok) { const s: HttpSettings = settings.value; const n: number = s.requestTimeoutMs; void n; }
66// @ts-expect-error a plain record is not HttpSettings (the brand)
67const forgedSettings: HttpSettings = { requestTimeoutMs: 1 };
68void forgedSettings;
69// Ids, prefixes and tree entries are plain strings too, parsed at each entry (#156, part 2)
70import { fetchObject } from '../../src/fetch.js';
71import { fetchCommit } from '../../src/commit.js';
72import { mergeBase, bestBases } from '../../src/merge.js';
73import { walkPath } from '../../src/read.js';
74import { lsRefsBody } from '../../src/lsrefs.js';
75import { encodeTree } from '../../src/objects.js';
76import { fetchBody } from '../../src/fetch.js';
77declare const mode: string;
78await fetchObject(t, { oid, filter: 'tree:0' });
79await fetchCommit(t, oid);
80await mergeBase(t, oid, oid);
81await walkPath(t, oid, [path]);
82void lsRefsBody([ref]);
83void encodeTree([{ mode, name: path, oid }]);
84void fetchBody({ wants: [oid], haves: [oid] });
85// a caller's own graph names its nodes with any strings
86void bestBases(new Map<string, { readonly parents: readonly string[] }>([['a', { parents: [] }]]), 'a', 'a');
Diagnostics7 git calls · 32 ms
CallStatusSizeTime032 ms
discover200191 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=4
git.response.bytes=191
git.server.agent=git/github-9922ec520325-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=191
git.pkt.payload.max=36
ls-refs20012 KiB · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=11990
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=152
git.pkt.data=151
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=11990
git.pkt.payload.max=122
git.ls_refs.count=151
git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 102004.2 KiB · hit4 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=4347
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=tree:0
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=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4347
git.pkt.payload.max=4247
git.sideband.band1.bytes=4247
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=10
git.pack.bytes=4247
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=a6caf8e129bea82c9bae4cbc7c130c9205add400
git.pack.full=10
Open pack map
fetchtree:0200919 B · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=919
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=800d30ba8923860bfc460ca884b7f9ba22083588
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=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=919
git.pkt.payload.max=892
git.sideband.band1.bytes=892
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=892
git.pack.trailer=5323b9266eea5ded637285d1c5320699f12be76e
Open pack map
fetchtree:02005.6 KiB · hit2 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=5724
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=58fabb6768b3f737ee9cd8bac647bdc27405fb4d
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=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=5724
git.pkt.payload.max=5697
git.sideband.band1.bytes=5697
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=5697
git.pack.trailer=be7e0453974a5fe832f9065a33bb7e3434c10e9b
Open pack map
fetchtree:0200746 B · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=17
git.response.bytes=746
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=1a4f84aea08d080a229290d401e77da8415108a0
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=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=746
git.pkt.payload.max=719
git.sideband.band1.bytes=719
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=719
git.pack.trailer=fd3904a205b94cd1bbf03c591c9acea7ca5dd5a7
Open pack map
fetch2001.6 KiB · hit17 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1613
git.response.cache=HIT
git.response.duration_ms=17
git.fetch.wants=07eef897865698b6fc24457390d4c5ff8f68a25d
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=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1613
git.pkt.payload.max=1586
git.sideband.band1.bytes=1586
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://github.com/ivarvong/ply
Ref
refs/heads/main
Commit
19912563f540228593df0c489082e5e2508e21e4
cf-ray
a5e2d79c595d14c2
Request
506a21d0…
Protocol
v2 · sha1
Agent
git/github-9922ec520325-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format