@navbook/cli 0.1.2 → 0.2.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.
Files changed (167) hide show
  1. package/dist/commands/complete.js +124 -0
  2. package/dist/commands/complete.js.map +1 -0
  3. package/dist/{cli/commands → commands}/compose.js +5 -3
  4. package/dist/commands/compose.js.map +1 -0
  5. package/dist/commands/doctor.js +56 -0
  6. package/dist/commands/doctor.js.map +1 -0
  7. package/dist/commands/entity.js +235 -0
  8. package/dist/commands/entity.js.map +1 -0
  9. package/dist/commands/feature.js +202 -0
  10. package/dist/commands/feature.js.map +1 -0
  11. package/dist/commands/init.js +23 -0
  12. package/dist/commands/init.js.map +1 -0
  13. package/dist/{cli/commands → commands}/install.js +1 -2
  14. package/dist/commands/install.js.map +1 -0
  15. package/dist/commands/issue.js +89 -0
  16. package/dist/commands/issue.js.map +1 -0
  17. package/dist/commands/policy.js +49 -0
  18. package/dist/commands/policy.js.map +1 -0
  19. package/dist/commands/pr.js +262 -0
  20. package/dist/commands/pr.js.map +1 -0
  21. package/dist/context.js +21 -0
  22. package/dist/context.js.map +1 -0
  23. package/dist/{cli/editor.js → editor.js} +1 -1
  24. package/dist/editor.js.map +1 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/install/completions.js.map +1 -0
  27. package/dist/{cli/install → install}/hook.js +1 -1
  28. package/dist/install/hook.js.map +1 -0
  29. package/dist/{cli/main.js → main.js} +10 -0
  30. package/dist/main.js.map +1 -0
  31. package/dist/{cli/program.js → program.js} +161 -23
  32. package/dist/program.js.map +1 -0
  33. package/dist/{cli/prompt.js → prompt.js} +11 -0
  34. package/dist/prompt.js.map +1 -0
  35. package/dist/render/colors.js.map +1 -0
  36. package/dist/render/detail.js +197 -0
  37. package/dist/render/detail.js.map +1 -0
  38. package/dist/render/table.js.map +1 -0
  39. package/dist/sort.js +77 -0
  40. package/dist/sort.js.map +1 -0
  41. package/package.json +15 -21
  42. package/README.md +0 -165
  43. package/dist/cli/commands/complete.d.ts +0 -9
  44. package/dist/cli/commands/complete.js +0 -72
  45. package/dist/cli/commands/complete.js.map +0 -1
  46. package/dist/cli/commands/compose.d.ts +0 -27
  47. package/dist/cli/commands/compose.js.map +0 -1
  48. package/dist/cli/commands/doctor.d.ts +0 -14
  49. package/dist/cli/commands/doctor.js +0 -127
  50. package/dist/cli/commands/doctor.js.map +0 -1
  51. package/dist/cli/commands/entity.d.ts +0 -55
  52. package/dist/cli/commands/entity.js +0 -209
  53. package/dist/cli/commands/entity.js.map +0 -1
  54. package/dist/cli/commands/init.d.ts +0 -11
  55. package/dist/cli/commands/init.js +0 -39
  56. package/dist/cli/commands/init.js.map +0 -1
  57. package/dist/cli/commands/install.d.ts +0 -17
  58. package/dist/cli/commands/install.js.map +0 -1
  59. package/dist/cli/commands/issue.d.ts +0 -12
  60. package/dist/cli/commands/issue.js +0 -42
  61. package/dist/cli/commands/issue.js.map +0 -1
  62. package/dist/cli/commands/pr.d.ts +0 -64
  63. package/dist/cli/commands/pr.js +0 -466
  64. package/dist/cli/commands/pr.js.map +0 -1
  65. package/dist/cli/commit-flow.d.ts +0 -27
  66. package/dist/cli/commit-flow.js +0 -47
  67. package/dist/cli/commit-flow.js.map +0 -1
  68. package/dist/cli/context.d.ts +0 -39
  69. package/dist/cli/context.js +0 -93
  70. package/dist/cli/context.js.map +0 -1
  71. package/dist/cli/editor.d.ts +0 -23
  72. package/dist/cli/editor.js.map +0 -1
  73. package/dist/cli/errors.d.ts +0 -17
  74. package/dist/cli/errors.js.map +0 -1
  75. package/dist/cli/history-checks.d.ts +0 -21
  76. package/dist/cli/history-checks.js +0 -134
  77. package/dist/cli/history-checks.js.map +0 -1
  78. package/dist/cli/install/completions.d.ts +0 -19
  79. package/dist/cli/install/completions.js.map +0 -1
  80. package/dist/cli/install/hook.d.ts +0 -20
  81. package/dist/cli/install/hook.js.map +0 -1
  82. package/dist/cli/main.d.ts +0 -14
  83. package/dist/cli/main.js.map +0 -1
  84. package/dist/cli/program.d.ts +0 -23
  85. package/dist/cli/program.js.map +0 -1
  86. package/dist/cli/prompt.d.ts +0 -22
  87. package/dist/cli/prompt.js.map +0 -1
  88. package/dist/cli/render/colors.d.ts +0 -13
  89. package/dist/cli/render/colors.js.map +0 -1
  90. package/dist/cli/render/detail.d.ts +0 -10
  91. package/dist/cli/render/detail.js +0 -105
  92. package/dist/cli/render/detail.js.map +0 -1
  93. package/dist/cli/render/table.d.ts +0 -19
  94. package/dist/cli/render/table.js.map +0 -1
  95. package/dist/cli/resolve.d.ts +0 -17
  96. package/dist/cli/resolve.js +0 -68
  97. package/dist/cli/resolve.js.map +0 -1
  98. package/dist/cli/workspace.d.ts +0 -52
  99. package/dist/cli/workspace.js +0 -178
  100. package/dist/cli/workspace.js.map +0 -1
  101. package/dist/core/comments.d.ts +0 -31
  102. package/dist/core/comments.js +0 -80
  103. package/dist/core/comments.js.map +0 -1
  104. package/dist/core/files.d.ts +0 -88
  105. package/dist/core/files.js +0 -441
  106. package/dist/core/files.js.map +0 -1
  107. package/dist/core/frontmatter.d.ts +0 -63
  108. package/dist/core/frontmatter.js +0 -149
  109. package/dist/core/frontmatter.js.map +0 -1
  110. package/dist/core/id.d.ts +0 -46
  111. package/dist/core/id.js +0 -66
  112. package/dist/core/id.js.map +0 -1
  113. package/dist/core/index.d.ts +0 -19
  114. package/dist/core/index.js +0 -20
  115. package/dist/core/index.js.map +0 -1
  116. package/dist/core/json.d.ts +0 -18
  117. package/dist/core/json.js +0 -51
  118. package/dist/core/json.js.map +0 -1
  119. package/dist/core/ops.d.ts +0 -92
  120. package/dist/core/ops.js +0 -173
  121. package/dist/core/ops.js.map +0 -1
  122. package/dist/core/person.d.ts +0 -20
  123. package/dist/core/person.js +0 -50
  124. package/dist/core/person.js.map +0 -1
  125. package/dist/core/query.d.ts +0 -30
  126. package/dist/core/query.js +0 -106
  127. package/dist/core/query.js.map +0 -1
  128. package/dist/core/refs.d.ts +0 -12
  129. package/dist/core/refs.js +0 -36
  130. package/dist/core/refs.js.map +0 -1
  131. package/dist/core/slug.d.ts +0 -22
  132. package/dist/core/slug.js +0 -40
  133. package/dist/core/slug.js.map +0 -1
  134. package/dist/core/time.d.ts +0 -14
  135. package/dist/core/time.js +0 -37
  136. package/dist/core/time.js.map +0 -1
  137. package/dist/core/tree.d.ts +0 -94
  138. package/dist/core/tree.js +0 -237
  139. package/dist/core/tree.js.map +0 -1
  140. package/dist/core/validate.d.ts +0 -55
  141. package/dist/core/validate.js +0 -312
  142. package/dist/core/validate.js.map +0 -1
  143. package/dist/git/config.d.ts +0 -12
  144. package/dist/git/config.js +0 -27
  145. package/dist/git/config.js.map +0 -1
  146. package/dist/git/exec.d.ts +0 -35
  147. package/dist/git/exec.js +0 -58
  148. package/dist/git/exec.js.map +0 -1
  149. package/dist/git/history.d.ts +0 -35
  150. package/dist/git/history.js +0 -82
  151. package/dist/git/history.js.map +0 -1
  152. package/dist/git/index-ops.d.ts +0 -20
  153. package/dist/git/index-ops.js +0 -45
  154. package/dist/git/index-ops.js.map +0 -1
  155. package/dist/git/merge.d.ts +0 -27
  156. package/dist/git/merge.js +0 -57
  157. package/dist/git/merge.js.map +0 -1
  158. package/dist/git/refscan.d.ts +0 -32
  159. package/dist/git/refscan.js +0 -82
  160. package/dist/git/refscan.js.map +0 -1
  161. package/dist/git/repo.d.ts +0 -45
  162. package/dist/git/repo.js +0 -95
  163. package/dist/git/repo.js.map +0 -1
  164. /package/dist/{cli/errors.js → errors.js} +0 -0
  165. /package/dist/{cli/install → install}/completions.js +0 -0
  166. /package/dist/{cli/render → render}/colors.js +0 -0
  167. /package/dist/{cli/render → render}/table.js +0 -0
@@ -1,466 +0,0 @@
1
- /**
2
- * `nav pr <verb>` — spec 04 §4.3.
3
- *
4
- * The seven shared verbs come from `entity.ts`; this module adds the three that
5
- * only pull requests have (`update`, `review`, `merge`) and the parts of the
6
- * shared verbs that must reach across branches, because a PR's files live on
7
- * the branch it proposes to merge (spec 03 §3.5).
8
- */
9
- import { newCommentFile, newPrFile, readRevisions, validateComment, validatePr, } from "../../core/files.js";
10
- import { MIN_PREFIX_LENGTH, resolvePrefix } from "../../core/id.js";
11
- import { entityJson, NAVBOOK_ROOT, toNdjson } from "../../core/json.js";
12
- import { planComment, planEntityOpen, planMergedBlock, planPrUpdate, RevisionUnchangedError, } from "../../core/ops.js";
13
- import { isQueryError, matchesQuery, parseQuery } from "../../core/query.js";
14
- import { allEntities, parseTree } from "../../core/tree.js";
15
- import { gitMaybe } from "../../git/exec.js";
16
- import { isAncestor, mergeBase, objectExists } from "../../git/history.js";
17
- import { add, commit, composeMessage } from "../../git/index-ops.js";
18
- import { canFastForward, commitMerge, conflictedPaths, fastForward, isAlreadyMerged, mergeHead, mergeNoCommit, } from "../../git/merge.js";
19
- import { catBlobs, listBranchRefs, lsTreeNames, lsTreeRecursive, } from "../../git/refscan.js";
20
- import { currentBranch, defaultBranch, isMergeInProgress, isTreeClean, resolveSha, } from "../../git/repo.js";
21
- import { commitReport, runPlan } from "../commit-flow.js";
22
- import { nowIso } from "../context.js";
23
- import { fail } from "../errors.js";
24
- import { asId, resolveEntity } from "../resolve.js";
25
- import { applyOps, loadRepo, repoPath, requireNavbook, scanAllIds, stage } from "../workspace.js";
26
- import { composeFile } from "./compose.js";
27
- import { cmdClose, cmdList, currentAuthor, rewritePlan, } from "./entity.js";
28
- const PR_OPEN_DIR = "prs/open";
29
- export function cmdPrOpen(ctx, opts) {
30
- requireNavbook(ctx);
31
- const source = currentBranch(ctx.repoRoot);
32
- if (!source)
33
- fail("HEAD is detached; check out the branch the pull request rides on");
34
- const target = opts.target ?? defaultBranch(ctx.repoRoot);
35
- if (!target)
36
- fail("could not determine a target branch; pass --target");
37
- if (target === source)
38
- fail(`a pull request cannot target its own branch (${source})`);
39
- const head = resolveSha(ctx.repoRoot, "HEAD");
40
- if (!head)
41
- fail("this branch has no commits yet");
42
- const base = mergeBase(ctx.repoRoot, "HEAD", target);
43
- if (!base)
44
- fail(`'${target}' does not exist, or shares no history with ${source}`);
45
- const title = opts.title ?? lastCommitSubject(ctx) ?? source;
46
- const created = nowIso(ctx);
47
- const revision = { head, base, date: created };
48
- const composed = composeFile(ctx, {
49
- message: opts.message,
50
- bufferName: "NAVBOOK_PR.md",
51
- noun: "pull request",
52
- render: (body) => newPrFile({
53
- title,
54
- author: currentAuthor(ctx),
55
- created,
56
- target,
57
- source,
58
- revisions: [revision],
59
- body,
60
- draft: opts.draft,
61
- labels: opts.label,
62
- assignee: opts.assignee,
63
- milestone: opts.milestone,
64
- }),
65
- validate: validatePr,
66
- });
67
- const finalTitle = typeof composed.parsed.fm.title === "string" ? composed.parsed.fm.title : title;
68
- const id = ctx.mintId(scanAllIds(ctx.navRoot));
69
- const { plan, dirPath } = planEntityOpen("pr", id, finalTitle, composed.content);
70
- runPlan(ctx, plan, { commit: opts.commit });
71
- ctx.stdout.write(`Created ${NAVBOOK_ROOT}/${dirPath}/ (#${id})\n`);
72
- ctx.stdout.write(`Targets ${target}, from ${source} at ${head.slice(0, 12)}\n`);
73
- if (opts.commit)
74
- ctx.stdout.write(`${commitReport(plan)}\n`);
75
- }
76
- function lastCommitSubject(ctx) {
77
- const subject = gitMaybe(["log", "-1", "--format=%s"], { cwd: ctx.repoRoot });
78
- return subject === null || subject === "" ? null : subject;
79
- }
80
- /* ------------------------------------------------------------------- update */
81
- export function cmdPrUpdate(ctx, prefix, opts) {
82
- const entity = resolveEntity(loadRepo(ctx), prefix, "pr");
83
- if (entity.status !== "open")
84
- fail(`#${entity.id} is ${entity.status}; only open pull requests take updates`);
85
- const head = resolveSha(ctx.repoRoot, "HEAD");
86
- if (!head)
87
- fail("this branch has no commits yet");
88
- const target = typeof entity.fm.target === "string" ? entity.fm.target : null;
89
- const base = target ? mergeBase(ctx.repoRoot, "HEAD", target) : null;
90
- if (!base)
91
- fail(`could not compute a merge base with '${target ?? "the target branch"}'`);
92
- let plan;
93
- try {
94
- plan = planPrUpdate(entity, { head, base, date: nowIso(ctx) });
95
- }
96
- catch (error) {
97
- if (error instanceof RevisionUnchangedError)
98
- fail(error.message);
99
- plan = rewritePlan(entity, () => {
100
- throw error;
101
- });
102
- }
103
- runPlan(ctx, plan, { commit: opts.commit });
104
- const count = readRevisions(entity.fm).length + 1;
105
- ctx.stdout.write(`Recorded revision ${count} of #${entity.id} head ${head.slice(0, 12)}\n`);
106
- if (opts.commit)
107
- ctx.stdout.write(`${commitReport(plan)}\n`);
108
- }
109
- export function cmdPrReview(ctx, prefix, opts) {
110
- const repo = loadRepo(ctx);
111
- const entity = resolveEntity(repo, prefix, "pr");
112
- if (opts.approve && opts.requestChanges) {
113
- fail("choose either --approve or --request-changes, not both");
114
- }
115
- const revisions = readRevisions(entity.fm);
116
- const latest = revisions[revisions.length - 1];
117
- const revision = opts.revision ? resolveRevision(entity, opts.revision) : latest?.head;
118
- if (!revision)
119
- fail(`#${entity.id} has no recorded revision to bind this review to`);
120
- if (opts.line && !opts.file)
121
- fail("--line needs --file");
122
- const verdict = opts.approve
123
- ? "approve"
124
- : opts.requestChanges
125
- ? "request-changes"
126
- : undefined;
127
- const isReview = verdict !== undefined || opts.file !== undefined;
128
- const base = {
129
- author: currentAuthor(ctx),
130
- body: "",
131
- ...(verdict ? { verdict } : {}),
132
- ...(isReview ? { revision } : {}),
133
- ...(opts.file ? { file: opts.file } : {}),
134
- ...(opts.line ? { line: opts.line } : {}),
135
- };
136
- const composed = composeFile(ctx, {
137
- message: opts.message,
138
- bufferName: "NAVBOOK_REVIEW.md",
139
- noun: verdict ? "review" : "comment",
140
- render: (body) => newCommentFile({ ...base, body }),
141
- validate: (parsed) => validateComment(parsed, { onPr: true }),
142
- });
143
- const id = ctx.mintId(scanAllIds(ctx.navRoot));
144
- const { plan, path } = planComment(entity, id, ctx.now(), composed.content, {
145
- review: isReview,
146
- });
147
- runPlan(ctx, plan, { commit: opts.commit });
148
- const label = verdict ? `Reviewed (${verdict})` : "Commented on";
149
- ctx.stdout.write(`${label} #${entity.id} ${NAVBOOK_ROOT}/${path} (#${id})\n`);
150
- if (isReview)
151
- ctx.stdout.write(`Bound to revision ${revision.slice(0, 12)}\n`);
152
- if (opts.commit)
153
- ctx.stdout.write(`${commitReport(plan)}\n`);
154
- }
155
- /** Accept a full SHA or an unambiguous prefix of a recorded revision head. */
156
- function resolveRevision(entity, wanted) {
157
- const heads = readRevisions(entity.fm).map((revision) => revision.head);
158
- const matches = heads.filter((head) => head.startsWith(wanted.toLowerCase()));
159
- if (matches.length === 1)
160
- return matches[0];
161
- if (matches.length === 0) {
162
- fail(`#${entity.id} has no recorded revision starting with '${wanted}'`, [
163
- ...heads.map((head) => ` ${head}`),
164
- ]);
165
- }
166
- fail(`'${wanted}' matches ${matches.length} recorded revisions of #${entity.id}`);
167
- }
168
- export function cmdPrList(ctx, terms, opts) {
169
- const extraColumns = [
170
- { header: "target", value: (entity) => stringField(entity, "target") },
171
- ];
172
- if (!opts.allRefs) {
173
- cmdList(ctx, "pr", terms, { ...opts, extraColumns });
174
- return;
175
- }
176
- const query = parseQuery(terms, "pr");
177
- if (isQueryError(query))
178
- fail(query.message);
179
- const found = scanRefsForOpenPrs(ctx);
180
- const matched = found.filter((entry) => matchesQuery(query, entry.entity));
181
- if (opts.json) {
182
- if (matched.length === 0)
183
- return;
184
- ctx.stdout.write(`${toNdjson(matched.map((entry) => entityJson(entry.entity, { refs: entry.refs.map((ref) => ref.short) })))}\n`);
185
- return;
186
- }
187
- if (matched.length === 0) {
188
- ctx.stdout.write("No pull requests match this query on any fetched branch.\n");
189
- return;
190
- }
191
- cmdList(ctx, "pr", terms, {
192
- ...opts,
193
- entities: matched.map((entry) => entry.entity),
194
- extraColumns: [
195
- ...extraColumns,
196
- {
197
- header: "refs",
198
- value: (entity) => (matched.find((entry) => entry.entity.id === entity.id)?.refs ?? [])
199
- .map((ref) => ref.short)
200
- .join(","),
201
- },
202
- ],
203
- });
204
- }
205
- /**
206
- * Enumerate open pull requests across local and fetched remote branches.
207
- *
208
- * The target branch does not show open PRs — they live on their source branches
209
- * — so this is how they are discovered (spec 03 §3.5). Local refs win when the
210
- * same PR appears on several, and every ref it was found on is reported: this
211
- * is the state of the branches you have fetched, not an aggregate truth.
212
- */
213
- function scanRefsForOpenPrs(ctx) {
214
- const cwd = ctx.repoRoot;
215
- const refs = listBranchRefs(cwd);
216
- const byId = new Map();
217
- for (const ref of refs) {
218
- const dirs = lsTreeNames(cwd, ref.full, `${NAVBOOK_ROOT}/${PR_OPEN_DIR}`).filter((name) => name !== ".gitkeep");
219
- if (dirs.length === 0)
220
- continue;
221
- for (const dirName of dirs) {
222
- const dirPath = `${NAVBOOK_ROOT}/${PR_OPEN_DIR}/${dirName}`;
223
- const paths = lsTreeRecursive(cwd, ref.full, dirPath);
224
- if (paths.length === 0)
225
- continue;
226
- const blobs = catBlobs(cwd, paths.map((path) => ({ ref: ref.full, path: `${dirPath}/${path}` })));
227
- const files = new Map();
228
- for (const path of paths) {
229
- const content = blobs.get(`${ref.full}:${dirPath}/${path}`);
230
- if (content !== undefined)
231
- files.set(`${PR_OPEN_DIR}/${dirName}/${path}`, content);
232
- }
233
- const entity = parseTree(files).prs[0];
234
- if (!entity)
235
- continue;
236
- const existing = byId.get(entity.id);
237
- if (!existing) {
238
- byId.set(entity.id, { entity, refs: [ref] });
239
- }
240
- else {
241
- // Prefer the copy on a local branch: it is the one you can act on.
242
- if (!ref.remote && existing.refs.every((seen) => seen.remote))
243
- existing.entity = entity;
244
- existing.refs.push(ref);
245
- }
246
- }
247
- }
248
- return [...byId.values()];
249
- }
250
- function stringField(entity, key) {
251
- const value = entity.fm[key];
252
- return typeof value === "string" ? value : "";
253
- }
254
- export function cmdPrMerge(ctx, prefix, opts) {
255
- if (opts.continue) {
256
- finishMerge(ctx, prefix);
257
- return;
258
- }
259
- if (!prefix)
260
- fail("nav pr merge needs the ID of the pull request to merge");
261
- if (isMergeInProgress(ctx.repoRoot)) {
262
- fail("a merge is already in progress", [
263
- "finish it with 'nav pr merge --continue', or 'git merge --abort'",
264
- ]);
265
- }
266
- if (!isTreeClean(ctx.repoRoot)) {
267
- fail("the working tree has changes; commit or stash them before merging");
268
- }
269
- const branch = currentBranch(ctx.repoRoot);
270
- if (!branch)
271
- fail("HEAD is detached; check out the target branch");
272
- const found = locatePr(ctx, prefix);
273
- const { entity, sourceRef } = found;
274
- const target = stringField(entity, "target");
275
- if (target !== branch) {
276
- fail(`#${entity.id} targets '${target}', but '${branch}' is checked out`, [
277
- `run 'git checkout ${target}' first`,
278
- ]);
279
- }
280
- if (isAlreadyMerged(ctx.repoRoot, sourceRef)) {
281
- fail(`#${entity.id} is already contained in ${branch}`, [
282
- "if it merged without being archived, run 'nav doctor --fix'",
283
- ]);
284
- }
285
- const title = stringField(entity, "title");
286
- const message = composeMessage(`Merge #${entity.id}: ${title}`, [{ key: "Refs", id: entity.id }]);
287
- if (!opts.noFf && canFastForward(ctx.repoRoot, sourceRef)) {
288
- // A fast-forward creates no commit to carry the move, so the archive
289
- // happens in the immediate follow-up commit that spec 02 §2.8 allows.
290
- fastForward(ctx.repoRoot, sourceRef);
291
- const archived = archiveIntoIndex(ctx, entity.id);
292
- recordMergedBlock(ctx, archived, null);
293
- return;
294
- }
295
- if (mergeNoCommit(ctx.repoRoot, sourceRef) === "conflict")
296
- reportConflict(ctx, entity.id);
297
- // The move is staged into the merge itself (04 §4.3), so the commit that
298
- // lands the branch is also the commit that files the discussion as merged.
299
- const archived = archiveIntoIndex(ctx, entity.id);
300
- recordMergedBlock(ctx, archived, commitMerge(ctx.repoRoot, message));
301
- }
302
- /** Finish a merge that was interrupted by conflicts. */
303
- function finishMerge(ctx, prefix) {
304
- if (isMergeInProgress(ctx.repoRoot)) {
305
- const conflicts = conflictedPaths(ctx.repoRoot);
306
- if (conflicts.length > 0) {
307
- fail("the merge still has unresolved conflicts", [
308
- ...conflicts.map((path) => ` ${path}`),
309
- "resolve them, 'git add' each one, then run 'nav pr merge --continue' again",
310
- ]);
311
- }
312
- }
313
- const entity = pendingMergePr(ctx, prefix);
314
- const title = stringField(entity, "title");
315
- const message = composeMessage(`Merge #${entity.id}: ${title}`, [{ key: "Refs", id: entity.id }]);
316
- const inProgress = isMergeInProgress(ctx.repoRoot);
317
- const archived = archiveIntoIndex(ctx, entity.id);
318
- const mergeSha = inProgress
319
- ? commitMerge(ctx.repoRoot, message)
320
- : (resolveSha(ctx.repoRoot, "HEAD") ?? null);
321
- recordMergedBlock(ctx, archived, mergeSha);
322
- }
323
- /** The PR whose source branch this in-progress merge is bringing in. */
324
- function pendingMergePr(ctx, prefix) {
325
- if (prefix)
326
- return locatePr(ctx, prefix).entity;
327
- const incoming = mergeHead(ctx.repoRoot);
328
- if (!incoming) {
329
- fail("no merge is in progress and no pull request was named", [
330
- "pass the ID: nav pr merge --continue <id>",
331
- ]);
332
- }
333
- const candidates = scanRefsForOpenPrs(ctx).filter((entry) => {
334
- const revisions = readRevisions(entry.entity.fm);
335
- const head = revisions[revisions.length - 1]?.head;
336
- return (head !== undefined &&
337
- objectExists(ctx.repoRoot, head) &&
338
- isAncestor(ctx.repoRoot, head, incoming));
339
- });
340
- const first = candidates[0];
341
- if (!first || candidates.length > 1) {
342
- fail("could not tell which pull request this merge belongs to", [
343
- "pass the ID: nav pr merge --continue <id>",
344
- ]);
345
- }
346
- return first.entity;
347
- }
348
- /**
349
- * Move the pull request into `prs/merged/` and stage the move without
350
- * committing, so the commit that lands the branch is also the commit that
351
- * files the discussion as merged (spec 04 §4.3).
352
- */
353
- function archiveIntoIndex(ctx, id) {
354
- const entity = loadRepo(ctx).byId.get(id);
355
- if (entity?.kind !== "pr") {
356
- fail(`#${id} did not arrive on this branch; the merge may not have carried its files`);
357
- }
358
- if (entity.status === "merged")
359
- return entity;
360
- const targetDir = `prs/merged/${entity.dirName}`;
361
- applyOps(ctx, [{ op: "move", from: entity.dirPath, to: targetDir }]);
362
- stage(ctx, [repoPath(entity.dirPath), repoPath(targetDir)]);
363
- return { ...entity, status: "merged", dirPath: targetDir, filePath: `${targetDir}/pr.md` };
364
- }
365
- /**
366
- * Record the `merged:` block in a follow-up commit. A merge commit cannot name
367
- * its own SHA, so this step is necessarily separate (spec 02 §2.7).
368
- */
369
- function recordMergedBlock(ctx, entity, mergeSha) {
370
- const identity = ctx.identity();
371
- const merged = {
372
- date: nowIso(ctx),
373
- by: identity.name ? `${identity.name} <${identity.email}>` : identity.email,
374
- ...(mergeSha ? { commit: mergeSha } : {}),
375
- };
376
- let plan;
377
- try {
378
- plan = planMergedBlock(entity, merged);
379
- }
380
- catch (error) {
381
- // The branch is already merged at this point, so say plainly what is left.
382
- fail(`#${entity.id} merged, but ${NAVBOOK_ROOT}/${entity.filePath} could not be updated`, [
383
- ` ${error instanceof Error ? error.message : String(error)}`,
384
- "the merge itself is committed; fix the file and commit the 'merged:' block by hand",
385
- ]);
386
- }
387
- applyOps(ctx, plan.ops);
388
- commit(ctx.repoRoot, composeMessage(plan.message, plan.trailers));
389
- ctx.stdout.write(`Merged #${entity.id} ${NAVBOOK_ROOT}/${entity.dirPath}/\n`);
390
- if (mergeSha)
391
- ctx.stdout.write(`Merge commit ${mergeSha.slice(0, 12)}\n`);
392
- }
393
- /**
394
- * Leave the merge in progress and say exactly how to finish it. The merge is
395
- * not aborted: the author's conflict resolution is worth keeping, and
396
- * `--continue` performs the archive step they would otherwise have to remember.
397
- */
398
- function reportConflict(ctx, id) {
399
- fail(`merging #${id} produced conflicts`, [
400
- ...conflictedPaths(ctx.repoRoot).map((path) => ` ${path}`),
401
- "resolve them, 'git add' each one, then run 'nav pr merge --continue'",
402
- "or abandon the merge with 'git merge --abort'",
403
- ]);
404
- }
405
- /**
406
- * Find a pull request for merging. It normally lives on another branch, so the
407
- * working tree is searched first and the refs afterwards.
408
- */
409
- function locatePr(ctx, prefix) {
410
- const found = scanRefsForOpenPrs(ctx);
411
- const resolution = resolvePrefix(asId(prefix), found.map((entry) => entry.entity.id));
412
- if (!resolution.ok) {
413
- switch (resolution.reason) {
414
- case "too-short":
415
- fail(`'${prefix}' is too short; ID prefixes must be at least ${MIN_PREFIX_LENGTH} characters`);
416
- break;
417
- case "not-found":
418
- fail(`no open pull request matches '${prefix}' on any fetched branch`);
419
- break;
420
- default:
421
- fail(`'${prefix}' is ambiguous; ${resolution.matches.length} pull requests match`, resolution.matches.map((id) => {
422
- const match = found.find((entry) => entry.entity.id === id);
423
- return ` #${id} ${match ? stringField(match.entity, "title") : ""}`;
424
- }));
425
- }
426
- }
427
- const entry = found.find((candidate) => candidate.entity.id === resolution.id);
428
- // `source:` is only SHOULD, so fall back to a local ref before a remote one:
429
- // a local branch is the copy the user can actually merge.
430
- const declared = stringField(entry.entity, "source");
431
- const ref = entry.refs.find((candidate) => candidate.short === declared)?.short ??
432
- entry.refs.find((candidate) => !candidate.remote)?.short ??
433
- entry.refs[0]?.short;
434
- return { entity: entry.entity, sourceRef: ref };
435
- }
436
- /* --------------------------------------------------------------------- close */
437
- /**
438
- * Decline a pull request.
439
- *
440
- * Its files usually live on the source branch, so when the ID is not in the
441
- * current tree the directory is first checked out from the ref that has it —
442
- * which is exactly the manual recipe spec 02 §2.8 describes for keeping a
443
- * durable record of a declined PR on the default branch.
444
- */
445
- export function cmdPrClose(ctx, prefix, opts) {
446
- const repo = loadRepo(ctx, { includeComments: false });
447
- const wanted = asId(prefix).toLowerCase();
448
- const present = allEntities(repo).some((entity) => entity.kind === "pr" && entity.id.startsWith(wanted));
449
- if (!present) {
450
- const materialized = materializeFromRef(ctx, prefix);
451
- ctx.stdout.write(`Brought #${materialized.id} onto this branch from ${materialized.ref} so it can be recorded\n`);
452
- }
453
- cmdClose(ctx, "pr", prefix, opts);
454
- }
455
- /** Check a pull request's directory out of the branch that carries it. */
456
- function materializeFromRef(ctx, prefix) {
457
- const { entity, sourceRef } = locatePr(ctx, prefix);
458
- const path = `${NAVBOOK_ROOT}/${entity.dirPath}`;
459
- if (gitMaybe(["checkout", sourceRef, "--", path], { cwd: ctx.repoRoot }) === null) {
460
- fail(`could not read ${path} from '${sourceRef}'`);
461
- }
462
- add(ctx.repoRoot, [path]);
463
- return { id: entity.id, ref: sourceRef };
464
- }
465
- export { scanRefsForOpenPrs };
466
- //# sourceMappingURL=pr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pr.js","sourceRoot":"","sources":["../../../src/cli/commands/pr.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,cAAc,EACd,SAAS,EAET,aAAa,EAEb,eAAe,EACf,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAGL,WAAW,EACX,cAAc,EACd,eAAe,EACf,YAAY,EACZ,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAqB,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,EACf,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,WAAW,EACX,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,mBAAm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jD,IAAI,QAAQ,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;QAClF,IAAI,CAAC,kBAAkB,IAAI,UAAU,SAAS,GAAG,CAAC,CAAC;IACrD,CAAC;IACD,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC3C,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,27 +0,0 @@
1
- /**
2
- * The `--commit` flag — spec 04 §4.2.
3
- *
4
- * Without it, a mutating command leaves its changes staged for the user's own
5
- * commit. With it, the change is wrapped in a well-formed `docs` commit — but
6
- * only if nothing unrelated is staged, so the user never has work swept into a
7
- * tracker commit by accident.
8
- */
9
- import type { Plan } from "../core/ops.ts";
10
- import type { Ctx } from "./context.ts";
11
- /**
12
- * Refuse to commit when the index already holds changes this operation did not
13
- * make. Called before any file is written, so a refusal leaves nothing behind.
14
- */
15
- export declare function assertNoUnrelatedStaged(ctx: Ctx, allowedPaths: readonly string[]): void;
16
- export interface RunPlanOptions {
17
- commit?: boolean;
18
- }
19
- export interface RunPlanResult {
20
- touched: string[];
21
- committed: boolean;
22
- message: string;
23
- }
24
- /** Apply a plan and, with `--commit`, wrap it in its `docs` commit. */
25
- export declare function runPlan(ctx: Ctx, plan: Plan, opts: RunPlanOptions): RunPlanResult;
26
- /** The one-line report printed after a committed change. */
27
- export declare function commitReport(plan: Plan): string;
@@ -1,47 +0,0 @@
1
- /**
2
- * The `--commit` flag — spec 04 §4.2.
3
- *
4
- * Without it, a mutating command leaves its changes staged for the user's own
5
- * commit. With it, the change is wrapped in a well-formed `docs` commit — but
6
- * only if nothing unrelated is staged, so the user never has work swept into a
7
- * tracker commit by accident.
8
- */
9
- import { planPaths } from "../core/ops.js";
10
- import { commit, composeMessage, stagedPaths } from "../git/index-ops.js";
11
- import { fail } from "./errors.js";
12
- import { applyOps, repoPath } from "./workspace.js";
13
- /** True when `path` is `allowed` or lives underneath it. */
14
- function isWithin(path, allowed) {
15
- return path === allowed || path.startsWith(`${allowed}/`);
16
- }
17
- /**
18
- * Refuse to commit when the index already holds changes this operation did not
19
- * make. Called before any file is written, so a refusal leaves nothing behind.
20
- */
21
- export function assertNoUnrelatedStaged(ctx, allowedPaths) {
22
- const staged = stagedPaths(ctx.repoRoot);
23
- const unrelated = staged.filter((path) => !allowedPaths.some((allowed) => isWithin(path, allowed)));
24
- if (unrelated.length === 0)
25
- return;
26
- fail("--commit refuses to run with unrelated changes already staged", [
27
- ...unrelated.slice(0, 10).map((path) => ` ${path}`),
28
- ...(unrelated.length > 10 ? [` ... and ${unrelated.length - 10} more`] : []),
29
- "commit or unstage them first, or omit --commit",
30
- ]);
31
- }
32
- /** Apply a plan and, with `--commit`, wrap it in its `docs` commit. */
33
- export function runPlan(ctx, plan, opts) {
34
- const allowed = planPaths(plan).map(repoPath);
35
- if (opts.commit)
36
- assertNoUnrelatedStaged(ctx, allowed);
37
- const { touched } = applyOps(ctx, plan.ops);
38
- const message = composeMessage(plan.message, plan.trailers);
39
- if (opts.commit)
40
- commit(ctx.repoRoot, message);
41
- return { touched, committed: opts.commit === true, message };
42
- }
43
- /** The one-line report printed after a committed change. */
44
- export function commitReport(plan) {
45
- return `Committed ${plan.message}`;
46
- }
47
- //# sourceMappingURL=commit-flow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commit-flow.js","sourceRoot":"","sources":["../../src/cli/commit-flow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE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AAG,EAAE,OAAO,CAAC,CAAC;IAEvD,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5D,IAAI,IAAI,CAAC,MAAM;QAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,OAAO,EAAE,CAAC;AAC/D,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,YAAY,CAAC,IAAU;IACrC,OAAO,aAAa,IAAI,CAAC,OAAO,EAAE,CAAC;AACrC,CAAC"}
@@ -1,39 +0,0 @@
1
- /**
2
- * Per-invocation context: where the repository is, what time it is, where IDs
3
- * come from, and how output is styled.
4
- *
5
- * This is the one place the conformance hooks `NAV_NOW` and `NAV_IDS` are
6
- * honored (see `doc/spec/fixtures/README.md`). Keeping them here means `core`
7
- * has no notion of testing and every command is deterministic under fixtures.
8
- */
9
- import { type Identity } from "../git/repo.ts";
10
- import { type Colors } from "./render/colors.ts";
11
- export declare const NAV_NOW_ENV = "NAV_NOW";
12
- export declare const NAV_IDS_ENV = "NAV_IDS";
13
- export interface Ctx {
14
- cwd: string;
15
- env: NodeJS.ProcessEnv;
16
- repoRoot: string;
17
- navRoot: string;
18
- hasNavbook: boolean;
19
- colors: Colors;
20
- stdout: NodeJS.WriteStream;
21
- stderr: NodeJS.WriteStream;
22
- /** Current instant; fixed by `NAV_NOW` under the conformance suite. */
23
- now(): Date;
24
- /** Mint an ID that is not already present in `taken`. */
25
- mintId(taken?: ReadonlySet<string>): string;
26
- /** Committer identity from git config. */
27
- identity(): Identity;
28
- }
29
- export interface MakeContextOptions {
30
- cwd?: string;
31
- env?: NodeJS.ProcessEnv;
32
- stdout?: NodeJS.WriteStream;
33
- stderr?: NodeJS.WriteStream;
34
- /** Skip repository discovery, for commands that work outside a repository. */
35
- requireRepo?: boolean;
36
- }
37
- export declare function makeContext(opts?: MakeContextOptions): Ctx;
38
- /** The current instant as an ISO 8601 string with second precision. */
39
- export declare function nowIso(ctx: Ctx): string;