@toon-protocol/rig 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -5
- package/dist/{chunk-S2BMLXAD.js → chunk-DCGV6ALH.js} +429 -14
- package/dist/chunk-DCGV6ALH.js.map +1 -0
- package/dist/{chunk-HMED76GU.js → chunk-JBFBD7HV.js} +99 -55
- package/dist/chunk-JBFBD7HV.js.map +1 -0
- package/dist/{chunk-UZZ2JKEC.js → chunk-X232W4TG.js} +491 -185
- package/dist/chunk-X232W4TG.js.map +1 -0
- package/dist/{ci-serve-PYEHIBN7.js → ci-serve-AYFZOY4O.js} +8 -19
- package/dist/ci-serve-AYFZOY4O.js.map +1 -0
- package/dist/cli/rig.js +4 -3
- package/dist/cli/rig.js.map +1 -1
- package/dist/index.d.ts +362 -20
- package/dist/index.js +494 -3
- package/dist/index.js.map +1 -1
- package/dist/{publisher-Cf6tKnZ3.d.ts → publisher-DgbfziOm.d.ts} +152 -26
- package/dist/standalone/index.d.ts +1 -1
- package/dist/{standalone-mode-W3ZEKC6M.js → standalone-mode-UQSP4677.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-HMED76GU.js.map +0 -1
- package/dist/chunk-S2BMLXAD.js.map +0 -1
- package/dist/chunk-UZZ2JKEC.js.map +0 -1
- package/dist/ci-serve-PYEHIBN7.js.map +0 -1
- /package/dist/{standalone-mode-W3ZEKC6M.js.map → standalone-mode-UQSP4677.js.map} +0 -0
package/README.md
CHANGED
|
@@ -212,7 +212,7 @@ rig pr status <event-id> applied
|
|
|
212
212
|
| `rig issue list` / `rig issue show <id>` | free | the repo's issues + comments from the terminal |
|
|
213
213
|
| `rig pr list` / `rig pr show <id>` | free | the repo's patches/PRs; `show` prints the full patch text (pipe to `git am`) |
|
|
214
214
|
| `rig issue create` | **paid** | file an issue (kind:1621) |
|
|
215
|
-
| `rig comment <
|
|
215
|
+
| `rig comment <target-event-id>` | **paid** | comment (NIP-22 kind:1111) on an issue/patch, or reply to a comment |
|
|
216
216
|
| `rig pr create` | **paid** | publish a patch (kind:1617) from real `git format-patch` |
|
|
217
217
|
| `rig pr status <event-id> <state>` | **paid** | set issue/patch status (kind:1630–1633) |
|
|
218
218
|
| `rig site publish [ref]` | **paid** | deploy a pushed repo as a permaweb site: build the ar.io path manifest (repo paths → Arweave txids) and upload it as one paid store write; prints the gateway URL |
|
|
@@ -744,7 +744,12 @@ per-event fee is quoted and confirmed before publishing; `--yes` skips, `--json`
|
|
|
744
744
|
without `--yes` is a free estimate:
|
|
745
745
|
|
|
746
746
|
- `rig issue create --title <t> [--body <b> | --body-file <f> | stdin] [--label <l>]…` — kind:1621.
|
|
747
|
-
- `rig comment <
|
|
747
|
+
- `rig comment <target-event-id> --body <b>` — NIP-22 kind:1111. The target is the
|
|
748
|
+
kind:1621 issue / kind:1617 patch (a top-level comment) or an existing kind:1111
|
|
749
|
+
comment (a reply). rig reads the target off the relay first, for free, so the
|
|
750
|
+
thread root's kind and author come from the wire: root scope is uppercase
|
|
751
|
+
`E`/`K`/`P`, the parent lowercase `e`/`k`/`p`, plus the repo `a` tag. Comments
|
|
752
|
+
published this way are invisible to rig releases older than 4.6.
|
|
748
753
|
- `rig pr create --title <t> (--range <A..B> | --patch-file <f>) [--body <b> | --body-file <f>] [--branch <name>]` —
|
|
749
754
|
kind:1617; `--range` runs real `git format-patch --stdout` locally and derives the
|
|
750
755
|
`commit`/`parent-commit` tags. A multi-commit range publishes ONE event carrying
|
|
@@ -770,8 +775,9 @@ delta: only locally-missing objects are downloaded, and `refs/remotes/<remote>/*
|
|
|
770
775
|
(tags → `refs/tags/*`) move with a `git fetch`-style report.
|
|
771
776
|
|
|
772
777
|
`rig issue list|show` and `rig pr list|show` are pure relay reads (kind:1621/1617 by
|
|
773
|
-
the repo `#a` tag; state from kind:1630-1633, latest wins;
|
|
774
|
-
`
|
|
778
|
+
the repo `#a` tag; state from kind:1630-1633, latest wins; comments under `show` —
|
|
779
|
+
NIP-22 kind:1111 matched on the uppercase `E` root tag, merged with legacy kind:1622
|
|
780
|
+
by `created_at`).
|
|
775
781
|
|
|
776
782
|
## Library
|
|
777
783
|
|
|
@@ -784,7 +790,9 @@ it — that stays behind the `Publisher` seam:
|
|
|
784
790
|
a deprecated alias; it is no longer a cap).
|
|
785
791
|
- `nip34-events.ts` — NIP-34 event builders returning `UnsignedEvent`:
|
|
786
792
|
`buildRepoAnnouncement` (30617), `buildRepoRefs` (30618), `buildIssue` (1621),
|
|
787
|
-
`buildComment` (
|
|
793
|
+
`buildComment` (NIP-22 1111; `LEGACY_COMMENT_KIND` = 1622 stays exported for
|
|
794
|
+
READING old threads and is never written), `buildPatch` (1617),
|
|
795
|
+
`buildStatus` (1630–1633).
|
|
788
796
|
- `repo-reader.ts` — `GitRepoReader`, read-only local-repo access via injection-safe
|
|
789
797
|
`execFile` git plumbing.
|
|
790
798
|
- `remote-state.ts` — `fetchRemoteState`, the "what does the remote have?" reader.
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARWEAVE_FETCH_TIMEOUT_MS,
|
|
3
3
|
ARWEAVE_GATEWAYS,
|
|
4
|
+
MAINTAINERS_TAG,
|
|
5
|
+
MAX_ARWEAVE_TAGS_PER_EVENT,
|
|
4
6
|
MissingIdentityError,
|
|
7
|
+
PAYOUT_TAG,
|
|
5
8
|
authorizedStatusAuthors,
|
|
6
|
-
buildRepoAnnouncement,
|
|
7
9
|
buildRepoRefs,
|
|
8
10
|
defaultWebSocketFactory,
|
|
9
11
|
isValidArweaveTxId,
|
|
12
|
+
parseMaintainers,
|
|
10
13
|
queryRelay,
|
|
11
14
|
resolveIdentity
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JBFBD7HV.js";
|
|
13
16
|
import {
|
|
14
17
|
defaultDaemonPort,
|
|
15
18
|
standaloneForced,
|
|
@@ -65,6 +68,203 @@ function createGitTag(opts) {
|
|
|
65
68
|
return hashGitObject("tag", Buffer.from(lines.join("\n"), "utf-8"));
|
|
66
69
|
}
|
|
67
70
|
|
|
71
|
+
// src/repo-announcement.ts
|
|
72
|
+
import { REPOSITORY_ANNOUNCEMENT_KIND } from "@toon-protocol/core/nip34";
|
|
73
|
+
var RELAYS_TAG = "relays";
|
|
74
|
+
var WEB_TAG = "web";
|
|
75
|
+
var EARLIEST_UNIQUE_COMMIT_MARKER = "euc";
|
|
76
|
+
function multiValueTag(name, values2) {
|
|
77
|
+
const kept = [];
|
|
78
|
+
const seen = /* @__PURE__ */ new Set();
|
|
79
|
+
for (const value of values2) {
|
|
80
|
+
const trimmed = value.trim();
|
|
81
|
+
if (trimmed.length === 0 || seen.has(trimmed)) continue;
|
|
82
|
+
seen.add(trimmed);
|
|
83
|
+
kept.push(trimmed);
|
|
84
|
+
}
|
|
85
|
+
return kept.length > 0 ? [[name, ...kept]] : [];
|
|
86
|
+
}
|
|
87
|
+
var named = (name) => (tag) => tag[0] === name;
|
|
88
|
+
var SLOTS = /* @__PURE__ */ new Map([
|
|
89
|
+
["d", { matches: named("d"), rewrite: (e) => [["d", e.repoId]] }],
|
|
90
|
+
[
|
|
91
|
+
"name",
|
|
92
|
+
{
|
|
93
|
+
matches: named("name"),
|
|
94
|
+
rewrite: (e) => e.name === void 0 ? null : [["name", e.name]]
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
[
|
|
98
|
+
"description",
|
|
99
|
+
{
|
|
100
|
+
matches: named("description"),
|
|
101
|
+
rewrite: (e) => e.description === void 0 ? null : [["description", e.description]]
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
"maintainers",
|
|
106
|
+
{
|
|
107
|
+
matches: named(MAINTAINERS_TAG),
|
|
108
|
+
rewrite: (e) => {
|
|
109
|
+
if (e.maintainers === void 0) return null;
|
|
110
|
+
const declared = parseMaintainers([
|
|
111
|
+
[MAINTAINERS_TAG, ...e.maintainers]
|
|
112
|
+
]);
|
|
113
|
+
return declared.length > 0 ? [[MAINTAINERS_TAG, ...declared]] : [];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
"payout",
|
|
119
|
+
{
|
|
120
|
+
matches: named(PAYOUT_TAG),
|
|
121
|
+
rewrite: (e) => e.payout === void 0 ? null : e.payout ? [[PAYOUT_TAG, e.payout.chain, e.payout.address]] : []
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
"relays",
|
|
126
|
+
{
|
|
127
|
+
matches: named(RELAYS_TAG),
|
|
128
|
+
rewrite: (e) => e.relays === void 0 ? null : e.relays ? multiValueTag(RELAYS_TAG, e.relays) : []
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
"web",
|
|
133
|
+
{
|
|
134
|
+
matches: named(WEB_TAG),
|
|
135
|
+
rewrite: (e) => e.web === void 0 ? null : e.web ? multiValueTag(WEB_TAG, e.web) : []
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
"euc",
|
|
140
|
+
{
|
|
141
|
+
// Only the euc marker is ours. Every other `r` tag is someone else's.
|
|
142
|
+
matches: (tag) => tag[0] === "r" && tag[2] === EARLIEST_UNIQUE_COMMIT_MARKER,
|
|
143
|
+
rewrite: (e) => e.earliestUniqueCommit === void 0 ? null : e.earliestUniqueCommit ? [["r", e.earliestUniqueCommit, EARLIEST_UNIQUE_COMMIT_MARKER]] : []
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
]);
|
|
147
|
+
function slotOf(tag) {
|
|
148
|
+
for (const [slot, spec] of SLOTS) {
|
|
149
|
+
if (spec.matches(tag)) return slot;
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
function rewrittenSlots(edits) {
|
|
154
|
+
const out = /* @__PURE__ */ new Map();
|
|
155
|
+
for (const [slot, spec] of SLOTS) {
|
|
156
|
+
const next = spec.rewrite(edits);
|
|
157
|
+
if (next !== null) out.set(slot, next);
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
function amendRepoAnnouncement(current, edits) {
|
|
162
|
+
const rewritten = rewrittenSlots(edits);
|
|
163
|
+
const tags = [["d", edits.repoId]];
|
|
164
|
+
const emitted = /* @__PURE__ */ new Set(["d"]);
|
|
165
|
+
for (const tag of current?.tags ?? []) {
|
|
166
|
+
const slot = slotOf(tag);
|
|
167
|
+
const replacement = slot === null ? void 0 : rewritten.get(slot);
|
|
168
|
+
if (slot === null || replacement === void 0) {
|
|
169
|
+
tags.push([...tag]);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (emitted.has(slot)) continue;
|
|
173
|
+
for (const next of replacement) tags.push([...next]);
|
|
174
|
+
emitted.add(slot);
|
|
175
|
+
}
|
|
176
|
+
for (const [slot, replacement] of rewritten) {
|
|
177
|
+
if (emitted.has(slot)) continue;
|
|
178
|
+
for (const next of replacement) tags.push([...next]);
|
|
179
|
+
emitted.add(slot);
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
kind: REPOSITORY_ANNOUNCEMENT_KIND,
|
|
183
|
+
content: current?.content ?? "",
|
|
184
|
+
tags,
|
|
185
|
+
created_at: Math.floor(Date.now() / 1e3)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function buildRepoAnnouncement(repoId, name, description, maintainers = [], payout) {
|
|
189
|
+
return amendRepoAnnouncement(null, {
|
|
190
|
+
repoId,
|
|
191
|
+
name,
|
|
192
|
+
description,
|
|
193
|
+
maintainers,
|
|
194
|
+
payout: payout ?? null
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
async function earliestUniqueCommit(reader) {
|
|
198
|
+
const all = await reader.rootCommits();
|
|
199
|
+
if (all.length === 0) return null;
|
|
200
|
+
if (all.length === 1) return all[0] ?? null;
|
|
201
|
+
const onDefaultBranch = await reader.rootCommits("HEAD");
|
|
202
|
+
const candidates = onDefaultBranch.length > 0 ? onDefaultBranch : all;
|
|
203
|
+
return [...candidates].sort()[0] ?? null;
|
|
204
|
+
}
|
|
205
|
+
function announcedEuc(current) {
|
|
206
|
+
for (const tag of current?.tags ?? []) {
|
|
207
|
+
if (tag[0] === "r" && tag[2] === EARLIEST_UNIQUE_COMMIT_MARKER) {
|
|
208
|
+
const sha = tag[1];
|
|
209
|
+
if (sha !== void 0 && sha.length > 0) return sha;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
function unionValues(current, name, additions) {
|
|
215
|
+
const existing = [];
|
|
216
|
+
for (const tag of current?.tags ?? []) {
|
|
217
|
+
if (tag[0] === name) existing.push(...tag.slice(1));
|
|
218
|
+
}
|
|
219
|
+
const out = [];
|
|
220
|
+
const seen = /* @__PURE__ */ new Set();
|
|
221
|
+
for (const value of [...existing, ...additions]) {
|
|
222
|
+
const trimmed = value.trim();
|
|
223
|
+
if (trimmed.length === 0 || seen.has(trimmed)) continue;
|
|
224
|
+
seen.add(trimmed);
|
|
225
|
+
out.push(trimmed);
|
|
226
|
+
}
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
229
|
+
function conformanceEdits(current, facts) {
|
|
230
|
+
const edits = {};
|
|
231
|
+
const relays = unionValues(current, RELAYS_TAG, facts.relays);
|
|
232
|
+
if (relays.length > 0) edits.relays = relays;
|
|
233
|
+
const web = unionValues(current, WEB_TAG, facts.web === null ? [] : [facts.web]);
|
|
234
|
+
if (web.length > 0) edits.web = web;
|
|
235
|
+
if (announcedEuc(current) === null && facts.earliestUniqueCommit !== null) {
|
|
236
|
+
edits.earliestUniqueCommit = facts.earliestUniqueCommit;
|
|
237
|
+
}
|
|
238
|
+
return edits;
|
|
239
|
+
}
|
|
240
|
+
function tagKey(tag) {
|
|
241
|
+
return JSON.stringify(tag);
|
|
242
|
+
}
|
|
243
|
+
function diffAnnouncementTags(current, next) {
|
|
244
|
+
const remaining = /* @__PURE__ */ new Map();
|
|
245
|
+
for (const tag of current?.tags ?? []) {
|
|
246
|
+
remaining.set(tagKey(tag), (remaining.get(tagKey(tag)) ?? 0) + 1);
|
|
247
|
+
}
|
|
248
|
+
const added = [];
|
|
249
|
+
for (const tag of next.tags) {
|
|
250
|
+
const key = tagKey(tag);
|
|
251
|
+
const count = remaining.get(key) ?? 0;
|
|
252
|
+
if (count > 0) remaining.set(key, count - 1);
|
|
253
|
+
else added.push([...tag]);
|
|
254
|
+
}
|
|
255
|
+
const removed = [];
|
|
256
|
+
for (const [key, count] of remaining) {
|
|
257
|
+
for (let i = 0; i < count; i += 1) {
|
|
258
|
+
removed.push(JSON.parse(key));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
added,
|
|
263
|
+
removed,
|
|
264
|
+
unchanged: added.length === 0 && removed.length === 0
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
68
268
|
// src/repo-reader.ts
|
|
69
269
|
import { execFile, spawn } from "child_process";
|
|
70
270
|
import { promisify } from "util";
|
|
@@ -261,6 +461,140 @@ var GitRepoReader = class {
|
|
|
261
461
|
}
|
|
262
462
|
return objects;
|
|
263
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Run git and hand each stdout line to `visit` as it arrives, never holding
|
|
466
|
+
* the whole output in memory. Returning `false` from `visit` ends the walk:
|
|
467
|
+
* the child is killed and the promise resolves with what was seen.
|
|
468
|
+
*
|
|
469
|
+
* Every other git call here buffers into one `execFile` string, which is
|
|
470
|
+
* fine for bounded output. These object walks are not bounded — they grow
|
|
471
|
+
* with the size of the repository — so on a repo big enough to need the
|
|
472
|
+
* object-map cap they would be the thing that breaks (#162).
|
|
473
|
+
*/
|
|
474
|
+
streamLines(args, visit) {
|
|
475
|
+
return new Promise((resolve, reject) => {
|
|
476
|
+
const child = spawn("git", args, {
|
|
477
|
+
cwd: this.repoPath,
|
|
478
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
479
|
+
});
|
|
480
|
+
let pending = "";
|
|
481
|
+
let stderr = "";
|
|
482
|
+
let settled = false;
|
|
483
|
+
const finish = (err) => {
|
|
484
|
+
if (settled) return;
|
|
485
|
+
settled = true;
|
|
486
|
+
if (err) reject(err);
|
|
487
|
+
else resolve();
|
|
488
|
+
};
|
|
489
|
+
child.stdout.setEncoding("utf-8");
|
|
490
|
+
child.stdout.on("data", (chunk) => {
|
|
491
|
+
if (settled) return;
|
|
492
|
+
pending += chunk;
|
|
493
|
+
let idx = pending.indexOf("\n");
|
|
494
|
+
while (idx !== -1) {
|
|
495
|
+
const line = pending.slice(0, idx);
|
|
496
|
+
pending = pending.slice(idx + 1);
|
|
497
|
+
if (line && !visit(line)) {
|
|
498
|
+
child.kill("SIGTERM");
|
|
499
|
+
return finish();
|
|
500
|
+
}
|
|
501
|
+
idx = pending.indexOf("\n");
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
child.stderr.on("data", (chunk) => {
|
|
505
|
+
stderr += chunk.toString("utf-8");
|
|
506
|
+
});
|
|
507
|
+
child.on("error", (err) => {
|
|
508
|
+
finish(
|
|
509
|
+
new GitError(
|
|
510
|
+
`failed to spawn git ${args[0]}: ${err.message}`,
|
|
511
|
+
void 0,
|
|
512
|
+
""
|
|
513
|
+
)
|
|
514
|
+
);
|
|
515
|
+
});
|
|
516
|
+
child.on("close", (code) => {
|
|
517
|
+
if (settled) return;
|
|
518
|
+
if (code !== 0) {
|
|
519
|
+
return finish(
|
|
520
|
+
new GitError(
|
|
521
|
+
`git ${args[0]} failed (exit ${code}): ${stderr.trim()}`,
|
|
522
|
+
code ?? void 0,
|
|
523
|
+
stderr.trim()
|
|
524
|
+
)
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
if (pending) visit(pending);
|
|
528
|
+
finish();
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Every object SHA in the local object database, in no particular order
|
|
534
|
+
* (`git cat-file --batch-all-objects --batch-check`, no bodies read).
|
|
535
|
+
*
|
|
536
|
+
* This is the honest answer to "what does this repository already have",
|
|
537
|
+
* which `rig fetch` needs to compute its delta. It deliberately does NOT
|
|
538
|
+
* consult the remote's kind:30618 `arweave` map: that map is capped (#162)
|
|
539
|
+
* and is a hint cache, never an index of local presence.
|
|
540
|
+
*
|
|
541
|
+
* Streamed, so the listing never has to fit in one buffer.
|
|
542
|
+
*/
|
|
543
|
+
async listAllObjectShas() {
|
|
544
|
+
const shas = [];
|
|
545
|
+
await this.streamLines(
|
|
546
|
+
[
|
|
547
|
+
"cat-file",
|
|
548
|
+
"--batch-check=%(objectname)",
|
|
549
|
+
"--batch-all-objects",
|
|
550
|
+
"--unordered"
|
|
551
|
+
],
|
|
552
|
+
(line) => {
|
|
553
|
+
shas.push(line);
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
);
|
|
557
|
+
return shas;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* SHAs of every object reachable from `tips`, newest first: commits in
|
|
561
|
+
* reverse-chronological order, each commit immediately followed by the
|
|
562
|
+
* trees and blobs it is the first to reference
|
|
563
|
+
* (`git rev-list --objects --in-commit-order`).
|
|
564
|
+
*
|
|
565
|
+
* Used to rank the kind:30618 object map when it exceeds
|
|
566
|
+
* `MAX_ARWEAVE_TAGS_PER_EVENT` (#162): the entries most likely to be wanted
|
|
567
|
+
* by the next clone or fetch are the ones nearest the tips. Tips that do
|
|
568
|
+
* not resolve locally (a remote ref we never fetched) are dropped rather
|
|
569
|
+
* than failing the walk.
|
|
570
|
+
*
|
|
571
|
+
* `limit` stops the walk once that many SHAs have been seen — the ranking
|
|
572
|
+
* caller never needs more than the cap, and a full walk of a repository big
|
|
573
|
+
* enough to hit the cap is exactly the work worth not doing. The walk is
|
|
574
|
+
* streamed, so neither its output nor this array is ever bigger than that.
|
|
575
|
+
*/
|
|
576
|
+
async reachableObjectsNewestFirst(tips, limit = Infinity) {
|
|
577
|
+
for (const tip of tips) assertRevision(tip, "tip");
|
|
578
|
+
const known = await this.filterExisting([...new Set(tips)]);
|
|
579
|
+
if (known.length === 0 || limit < 1) return [];
|
|
580
|
+
const shas = [];
|
|
581
|
+
await this.streamLines(
|
|
582
|
+
[
|
|
583
|
+
"rev-list",
|
|
584
|
+
"--objects",
|
|
585
|
+
"--in-commit-order",
|
|
586
|
+
...known,
|
|
587
|
+
"--"
|
|
588
|
+
// nothing user-supplied can become a pathspec
|
|
589
|
+
],
|
|
590
|
+
(line) => {
|
|
591
|
+
const spaceIdx = line.indexOf(" ");
|
|
592
|
+
shas.push(spaceIdx === -1 ? line : line.slice(0, spaceIdx));
|
|
593
|
+
return shas.length < limit;
|
|
594
|
+
}
|
|
595
|
+
);
|
|
596
|
+
return shas;
|
|
597
|
+
}
|
|
264
598
|
/**
|
|
265
599
|
* List every blob (file) reachable from a ref's root tree, recursively,
|
|
266
600
|
* with the path it is served at (#368: the ar.io site manifest join key).
|
|
@@ -485,6 +819,46 @@ var GitRepoReader = class {
|
|
|
485
819
|
}
|
|
486
820
|
return parents;
|
|
487
821
|
}
|
|
822
|
+
/**
|
|
823
|
+
* SHAs of the repo's ROOT commits — the parentless commits a history starts
|
|
824
|
+
* from — via `git rev-list --max-parents=0`.
|
|
825
|
+
*
|
|
826
|
+
* The repo's *earliest unique commit* (NIP-34's `euc` fork-identity tag) is
|
|
827
|
+
* chosen from these; the choosing rule lives in `repo-announcement.ts`.
|
|
828
|
+
*
|
|
829
|
+
* @param rev - Consider only roots reachable from this revision. Omit for
|
|
830
|
+
* every root in the repository (`--all`).
|
|
831
|
+
* @returns The roots in `rev-list` order, or `[]` when the revision does not
|
|
832
|
+
* resolve — an unborn `HEAD` in a repo with no commits is not an error.
|
|
833
|
+
*/
|
|
834
|
+
async rootCommits(rev) {
|
|
835
|
+
const args = ["rev-list", "--max-parents=0"];
|
|
836
|
+
if (rev === void 0) {
|
|
837
|
+
args.push("--all");
|
|
838
|
+
} else {
|
|
839
|
+
assertRevision(rev, "rev");
|
|
840
|
+
args.push(rev);
|
|
841
|
+
}
|
|
842
|
+
args.push("--");
|
|
843
|
+
const { stdout, exitCode } = await this.git(args, {
|
|
844
|
+
allowExitCodes: [128]
|
|
845
|
+
});
|
|
846
|
+
if (exitCode !== 0) return [];
|
|
847
|
+
const roots = [];
|
|
848
|
+
for (const line of stdout.split("\n")) {
|
|
849
|
+
const sha = line.trim();
|
|
850
|
+
if (!sha) continue;
|
|
851
|
+
if (!FULL_SHA_RE.test(sha)) {
|
|
852
|
+
throw new GitError(
|
|
853
|
+
`unexpected rev-list --max-parents=0 line: ${JSON.stringify(line)}`,
|
|
854
|
+
void 0,
|
|
855
|
+
""
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
roots.push(sha);
|
|
859
|
+
}
|
|
860
|
+
return roots;
|
|
861
|
+
}
|
|
488
862
|
/**
|
|
489
863
|
* Resolve a ref/revision to a full SHA via `git rev-parse --verify`.
|
|
490
864
|
* Throws {@link GitError} when the name doesn't resolve.
|
|
@@ -1140,6 +1514,7 @@ async function planPush(options) {
|
|
|
1140
1514
|
if (refname !== headSymref) newRefs[refname] = sha;
|
|
1141
1515
|
}
|
|
1142
1516
|
const announceNeeded = !remoteState.announced;
|
|
1517
|
+
const euc = announceNeeded ? await earliestUniqueCommit(repoReader) : null;
|
|
1143
1518
|
const totalObjectBytes = objects.reduce((sum, o) => sum + o.size, 0);
|
|
1144
1519
|
const uploadFee = objects.reduce(
|
|
1145
1520
|
(sum, o) => sum + uploadChargeFor(feeRates, o.size),
|
|
@@ -1158,7 +1533,9 @@ async function planPush(options) {
|
|
|
1158
1533
|
announceNeeded,
|
|
1159
1534
|
announcement: {
|
|
1160
1535
|
name: options.announcement?.name ?? repoId,
|
|
1161
|
-
description: options.announcement?.description ?? ""
|
|
1536
|
+
description: options.announcement?.description ?? "",
|
|
1537
|
+
...options.announcement?.web ? { web: options.announcement.web } : {},
|
|
1538
|
+
...euc ? { earliestUniqueCommit: euc } : {}
|
|
1162
1539
|
},
|
|
1163
1540
|
estimate: {
|
|
1164
1541
|
objectCount: objects.length,
|
|
@@ -1172,6 +1549,32 @@ async function planPush(options) {
|
|
|
1172
1549
|
};
|
|
1173
1550
|
}
|
|
1174
1551
|
var READ_BATCH_SIZE = 100;
|
|
1552
|
+
async function boundObjectMap(merged, plan, repoReader) {
|
|
1553
|
+
if (merged.size <= MAX_ARWEAVE_TAGS_PER_EVENT) return merged;
|
|
1554
|
+
const kept = /* @__PURE__ */ new Map();
|
|
1555
|
+
const take = (sha) => {
|
|
1556
|
+
if (kept.size >= MAX_ARWEAVE_TAGS_PER_EVENT || kept.has(sha)) return;
|
|
1557
|
+
const txId = merged.get(sha);
|
|
1558
|
+
if (txId !== void 0) kept.set(sha, txId);
|
|
1559
|
+
};
|
|
1560
|
+
for (const object of plan.objects) take(object.sha);
|
|
1561
|
+
if (kept.size < MAX_ARWEAVE_TAGS_PER_EVENT) {
|
|
1562
|
+
const tips = [...new Set(Object.values(plan.newRefs))];
|
|
1563
|
+
const reachable = await repoReader.reachableObjectsNewestFirst(
|
|
1564
|
+
tips,
|
|
1565
|
+
MAX_ARWEAVE_TAGS_PER_EVENT
|
|
1566
|
+
);
|
|
1567
|
+
for (const sha of reachable) {
|
|
1568
|
+
if (kept.size >= MAX_ARWEAVE_TAGS_PER_EVENT) break;
|
|
1569
|
+
take(sha);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
for (const [sha, txId] of merged) {
|
|
1573
|
+
if (kept.size >= MAX_ARWEAVE_TAGS_PER_EVENT) break;
|
|
1574
|
+
if (!kept.has(sha)) kept.set(sha, txId);
|
|
1575
|
+
}
|
|
1576
|
+
return kept;
|
|
1577
|
+
}
|
|
1175
1578
|
async function executePush(options) {
|
|
1176
1579
|
const { plan, publisher, remoteState, repoReader, relayUrls } = options;
|
|
1177
1580
|
const merged = new Map([...remoteState.shaToTxId, ...plan.knownShaToTxId]);
|
|
@@ -1230,18 +1633,22 @@ async function executePush(options) {
|
|
|
1230
1633
|
}
|
|
1231
1634
|
let announceReceipt = null;
|
|
1232
1635
|
if (plan.announceNeeded && !remoteState.announced) {
|
|
1233
|
-
const announceEvent =
|
|
1234
|
-
plan.repoId,
|
|
1235
|
-
plan.announcement.name,
|
|
1236
|
-
plan.announcement.description
|
|
1237
|
-
|
|
1636
|
+
const announceEvent = amendRepoAnnouncement(null, {
|
|
1637
|
+
repoId: plan.repoId,
|
|
1638
|
+
name: plan.announcement.name,
|
|
1639
|
+
description: plan.announcement.description,
|
|
1640
|
+
relays: relayUrls,
|
|
1641
|
+
...plan.announcement.web ? { web: [plan.announcement.web] } : {},
|
|
1642
|
+
...plan.announcement.earliestUniqueCommit ? { earliestUniqueCommit: plan.announcement.earliestUniqueCommit } : {}
|
|
1643
|
+
});
|
|
1238
1644
|
announceReceipt = await publisher.publishEvent(announceEvent, relayUrls);
|
|
1239
1645
|
totalFeePaid += announceReceipt.feePaid;
|
|
1240
1646
|
}
|
|
1647
|
+
const published = await boundObjectMap(merged, plan, repoReader);
|
|
1241
1648
|
const refsEvent = buildRepoRefs(
|
|
1242
1649
|
plan.repoId,
|
|
1243
1650
|
plan.newRefs,
|
|
1244
|
-
Object.fromEntries(
|
|
1651
|
+
Object.fromEntries(published)
|
|
1245
1652
|
);
|
|
1246
1653
|
const refsReceipt = await publisher.publishEvent(refsEvent, relayUrls);
|
|
1247
1654
|
totalFeePaid += refsReceipt.feePaid;
|
|
@@ -1256,7 +1663,7 @@ async function executePush(options) {
|
|
|
1256
1663
|
uploads,
|
|
1257
1664
|
announceReceipt,
|
|
1258
1665
|
refsReceipt,
|
|
1259
|
-
arweaveMap:
|
|
1666
|
+
arweaveMap: published,
|
|
1260
1667
|
totalFeePaid
|
|
1261
1668
|
};
|
|
1262
1669
|
}
|
|
@@ -2886,7 +3293,7 @@ function emitCliError(io, json, command, err) {
|
|
|
2886
3293
|
|
|
2887
3294
|
// src/cli/ci-status.ts
|
|
2888
3295
|
import { parseArgs as parseArgs2 } from "util";
|
|
2889
|
-
import { REPOSITORY_ANNOUNCEMENT_KIND } from "@toon-protocol/core/nip34";
|
|
3296
|
+
import { REPOSITORY_ANNOUNCEMENT_KIND as REPOSITORY_ANNOUNCEMENT_KIND2 } from "@toon-protocol/core/nip34";
|
|
2890
3297
|
|
|
2891
3298
|
// src/cli/git-config.ts
|
|
2892
3299
|
import { execFile as execFile3 } from "child_process";
|
|
@@ -3541,7 +3948,7 @@ async function runCiStatus(args, deps) {
|
|
|
3541
3948
|
"#a": [repoAddr]
|
|
3542
3949
|
},
|
|
3543
3950
|
{
|
|
3544
|
-
kinds: [
|
|
3951
|
+
kinds: [REPOSITORY_ANNOUNCEMENT_KIND2],
|
|
3545
3952
|
authors: [owner],
|
|
3546
3953
|
"#d": [repoId]
|
|
3547
3954
|
}
|
|
@@ -3550,7 +3957,7 @@ async function runCiStatus(args, deps) {
|
|
|
3550
3957
|
);
|
|
3551
3958
|
let announce = null;
|
|
3552
3959
|
for (const ev of events) {
|
|
3553
|
-
if (ev.kind !==
|
|
3960
|
+
if (ev.kind !== REPOSITORY_ANNOUNCEMENT_KIND2 || ev.pubkey.toLowerCase() !== owner)
|
|
3554
3961
|
continue;
|
|
3555
3962
|
if (!ev.tags.some((t) => t[0] === "d" && t[1] === repoId)) continue;
|
|
3556
3963
|
if (announce === null || ev.created_at > announce.created_at || ev.created_at === announce.created_at && ev.id < announce.id) {
|
|
@@ -3646,6 +4053,14 @@ export {
|
|
|
3646
4053
|
createGitTree,
|
|
3647
4054
|
createGitCommit,
|
|
3648
4055
|
createGitTag,
|
|
4056
|
+
RELAYS_TAG,
|
|
4057
|
+
WEB_TAG,
|
|
4058
|
+
EARLIEST_UNIQUE_COMMIT_MARKER,
|
|
4059
|
+
amendRepoAnnouncement,
|
|
4060
|
+
buildRepoAnnouncement,
|
|
4061
|
+
earliestUniqueCommit,
|
|
4062
|
+
conformanceEdits,
|
|
4063
|
+
diffAnnouncementTags,
|
|
3649
4064
|
GitError,
|
|
3650
4065
|
GitRepoReader,
|
|
3651
4066
|
DEFAULT_CONCURRENCY,
|
|
@@ -3759,4 +4174,4 @@ export {
|
|
|
3759
4174
|
assembleCiStatus,
|
|
3760
4175
|
runCiStatus
|
|
3761
4176
|
};
|
|
3762
|
-
//# sourceMappingURL=chunk-
|
|
4177
|
+
//# sourceMappingURL=chunk-DCGV6ALH.js.map
|