@navbook/cli 0.1.1 → 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.
- package/dist/commands/complete.js +124 -0
- package/dist/commands/complete.js.map +1 -0
- package/dist/{cli/commands → commands}/compose.js +5 -3
- package/dist/commands/compose.js.map +1 -0
- package/dist/commands/doctor.js +56 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/entity.js +235 -0
- package/dist/commands/entity.js.map +1 -0
- package/dist/commands/feature.js +202 -0
- package/dist/commands/feature.js.map +1 -0
- package/dist/commands/init.js +23 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/{cli/commands → commands}/install.js +1 -2
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/issue.js +89 -0
- package/dist/commands/issue.js.map +1 -0
- package/dist/commands/policy.js +49 -0
- package/dist/commands/policy.js.map +1 -0
- package/dist/commands/pr.js +262 -0
- package/dist/commands/pr.js.map +1 -0
- package/dist/context.js +21 -0
- package/dist/context.js.map +1 -0
- package/dist/{cli/editor.js → editor.js} +1 -1
- package/dist/editor.js.map +1 -0
- package/dist/errors.js.map +1 -0
- package/dist/install/completions.js.map +1 -0
- package/dist/{cli/install → install}/hook.js +1 -1
- package/dist/install/hook.js.map +1 -0
- package/dist/{cli/main.js → main.js} +10 -0
- package/dist/main.js.map +1 -0
- package/dist/program.js +356 -0
- package/dist/program.js.map +1 -0
- package/dist/{cli/prompt.js → prompt.js} +11 -0
- package/dist/prompt.js.map +1 -0
- package/dist/render/colors.js.map +1 -0
- package/dist/render/detail.js +197 -0
- package/dist/render/detail.js.map +1 -0
- package/dist/render/table.js.map +1 -0
- package/dist/sort.js +77 -0
- package/dist/sort.js.map +1 -0
- package/package.json +15 -21
- package/README.md +0 -165
- package/dist/cli/commands/complete.d.ts +0 -9
- package/dist/cli/commands/complete.js +0 -72
- package/dist/cli/commands/complete.js.map +0 -1
- package/dist/cli/commands/compose.d.ts +0 -27
- package/dist/cli/commands/compose.js.map +0 -1
- package/dist/cli/commands/doctor.d.ts +0 -14
- package/dist/cli/commands/doctor.js +0 -127
- package/dist/cli/commands/doctor.js.map +0 -1
- package/dist/cli/commands/entity.d.ts +0 -55
- package/dist/cli/commands/entity.js +0 -209
- package/dist/cli/commands/entity.js.map +0 -1
- package/dist/cli/commands/init.d.ts +0 -11
- package/dist/cli/commands/init.js +0 -39
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/install.d.ts +0 -17
- package/dist/cli/commands/install.js.map +0 -1
- package/dist/cli/commands/issue.d.ts +0 -12
- package/dist/cli/commands/issue.js +0 -42
- package/dist/cli/commands/issue.js.map +0 -1
- package/dist/cli/commands/pr.d.ts +0 -64
- package/dist/cli/commands/pr.js +0 -466
- package/dist/cli/commands/pr.js.map +0 -1
- package/dist/cli/commit-flow.d.ts +0 -27
- package/dist/cli/commit-flow.js +0 -47
- package/dist/cli/commit-flow.js.map +0 -1
- package/dist/cli/context.d.ts +0 -39
- package/dist/cli/context.js +0 -93
- package/dist/cli/context.js.map +0 -1
- package/dist/cli/editor.d.ts +0 -23
- package/dist/cli/editor.js.map +0 -1
- package/dist/cli/errors.d.ts +0 -17
- package/dist/cli/errors.js.map +0 -1
- package/dist/cli/history-checks.d.ts +0 -21
- package/dist/cli/history-checks.js +0 -134
- package/dist/cli/history-checks.js.map +0 -1
- package/dist/cli/install/completions.d.ts +0 -19
- package/dist/cli/install/completions.js.map +0 -1
- package/dist/cli/install/hook.d.ts +0 -20
- package/dist/cli/install/hook.js.map +0 -1
- package/dist/cli/main.d.ts +0 -14
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/program.d.ts +0 -23
- package/dist/cli/program.js +0 -204
- package/dist/cli/program.js.map +0 -1
- package/dist/cli/prompt.d.ts +0 -22
- package/dist/cli/prompt.js.map +0 -1
- package/dist/cli/render/colors.d.ts +0 -13
- package/dist/cli/render/colors.js.map +0 -1
- package/dist/cli/render/detail.d.ts +0 -10
- package/dist/cli/render/detail.js +0 -105
- package/dist/cli/render/detail.js.map +0 -1
- package/dist/cli/render/table.d.ts +0 -19
- package/dist/cli/render/table.js.map +0 -1
- package/dist/cli/resolve.d.ts +0 -17
- package/dist/cli/resolve.js +0 -68
- package/dist/cli/resolve.js.map +0 -1
- package/dist/cli/workspace.d.ts +0 -52
- package/dist/cli/workspace.js +0 -178
- package/dist/cli/workspace.js.map +0 -1
- package/dist/core/comments.d.ts +0 -31
- package/dist/core/comments.js +0 -80
- package/dist/core/comments.js.map +0 -1
- package/dist/core/files.d.ts +0 -88
- package/dist/core/files.js +0 -441
- package/dist/core/files.js.map +0 -1
- package/dist/core/frontmatter.d.ts +0 -63
- package/dist/core/frontmatter.js +0 -149
- package/dist/core/frontmatter.js.map +0 -1
- package/dist/core/id.d.ts +0 -46
- package/dist/core/id.js +0 -66
- package/dist/core/id.js.map +0 -1
- package/dist/core/index.d.ts +0 -19
- package/dist/core/index.js +0 -20
- package/dist/core/index.js.map +0 -1
- package/dist/core/json.d.ts +0 -18
- package/dist/core/json.js +0 -51
- package/dist/core/json.js.map +0 -1
- package/dist/core/ops.d.ts +0 -92
- package/dist/core/ops.js +0 -173
- package/dist/core/ops.js.map +0 -1
- package/dist/core/person.d.ts +0 -20
- package/dist/core/person.js +0 -50
- package/dist/core/person.js.map +0 -1
- package/dist/core/query.d.ts +0 -30
- package/dist/core/query.js +0 -106
- package/dist/core/query.js.map +0 -1
- package/dist/core/refs.d.ts +0 -12
- package/dist/core/refs.js +0 -36
- package/dist/core/refs.js.map +0 -1
- package/dist/core/slug.d.ts +0 -22
- package/dist/core/slug.js +0 -40
- package/dist/core/slug.js.map +0 -1
- package/dist/core/time.d.ts +0 -14
- package/dist/core/time.js +0 -37
- package/dist/core/time.js.map +0 -1
- package/dist/core/tree.d.ts +0 -94
- package/dist/core/tree.js +0 -237
- package/dist/core/tree.js.map +0 -1
- package/dist/core/validate.d.ts +0 -55
- package/dist/core/validate.js +0 -312
- package/dist/core/validate.js.map +0 -1
- package/dist/git/config.d.ts +0 -12
- package/dist/git/config.js +0 -27
- package/dist/git/config.js.map +0 -1
- package/dist/git/exec.d.ts +0 -35
- package/dist/git/exec.js +0 -58
- package/dist/git/exec.js.map +0 -1
- package/dist/git/history.d.ts +0 -35
- package/dist/git/history.js +0 -82
- package/dist/git/history.js.map +0 -1
- package/dist/git/index-ops.d.ts +0 -20
- package/dist/git/index-ops.js +0 -45
- package/dist/git/index-ops.js.map +0 -1
- package/dist/git/merge.d.ts +0 -27
- package/dist/git/merge.js +0 -57
- package/dist/git/merge.js.map +0 -1
- package/dist/git/refscan.d.ts +0 -32
- package/dist/git/refscan.js +0 -82
- package/dist/git/refscan.js.map +0 -1
- package/dist/git/repo.d.ts +0 -45
- package/dist/git/repo.js +0 -95
- package/dist/git/repo.js.map +0 -1
- /package/dist/{cli/errors.js → errors.js} +0 -0
- /package/dist/{cli/install → install}/completions.js +0 -0
- /package/dist/{cli/render → render}/colors.js +0 -0
- /package/dist/{cli/render → render}/table.js +0 -0
package/dist/core/validate.js
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format validation — the `nav doctor` checks of spec 04 §4.3.
|
|
3
|
-
*
|
|
4
|
-
* Checks D1–D6 and D8 are decidable from the tree alone and live here. D7, D9
|
|
5
|
-
* and D10 need git archaeology; their tree-side halves live here and the
|
|
6
|
-
* history queries are supplied by the CLI.
|
|
7
|
-
*/
|
|
8
|
-
import { parseCommentFileName } from "./comments.js";
|
|
9
|
-
import { readRevisions, validateComment, validateIssue, validatePr, } from "./files.js";
|
|
10
|
-
import { isId } from "./id.js";
|
|
11
|
-
import { extractProseRefs, extractTrailerRefs } from "./refs.js";
|
|
12
|
-
import { parseDirName } from "./slug.js";
|
|
13
|
-
import { allEntities, parseTree, statusDir, } from "./tree.js";
|
|
14
|
-
export const CHECKS = ["D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10"];
|
|
15
|
-
export const CHECK_LEVEL = {
|
|
16
|
-
D1: "error",
|
|
17
|
-
D2: "error",
|
|
18
|
-
D3: "error",
|
|
19
|
-
D4: "error",
|
|
20
|
-
D5: "error",
|
|
21
|
-
D6: "error",
|
|
22
|
-
D7: "error",
|
|
23
|
-
D8: "warning",
|
|
24
|
-
D9: "warning",
|
|
25
|
-
D10: "warning",
|
|
26
|
-
};
|
|
27
|
-
/** Run every tree-decidable check. */
|
|
28
|
-
export function validateTree(files, opts = {}) {
|
|
29
|
-
return validateRepo(parseTree(files), opts);
|
|
30
|
-
}
|
|
31
|
-
/** Run every tree-decidable check against an already-parsed repository. */
|
|
32
|
-
export function validateRepo(repo, opts = {}) {
|
|
33
|
-
const out = [];
|
|
34
|
-
out.push(...checkNames(repo));
|
|
35
|
-
out.push(...checkFrontmatter(repo));
|
|
36
|
-
const { duplicates, uniqueIds } = collectIds(repo);
|
|
37
|
-
out.push(...duplicates);
|
|
38
|
-
out.push(...checkStatusUniqueness(repo));
|
|
39
|
-
out.push(...checkReplyTargets(repo));
|
|
40
|
-
out.push(...checkReviewRevisions(repo));
|
|
41
|
-
out.push(...checkDanglingRefs(repo, uniqueIds, opts.commitMessages ?? []));
|
|
42
|
-
return sortDiagnostics(out);
|
|
43
|
-
}
|
|
44
|
-
/** Stable ordering: by check, then path, then message. */
|
|
45
|
-
export function sortDiagnostics(diagnostics) {
|
|
46
|
-
return [...diagnostics].sort((a, b) => {
|
|
47
|
-
if (a.check !== b.check)
|
|
48
|
-
return CHECKS.indexOf(a.check) - CHECKS.indexOf(b.check);
|
|
49
|
-
if (a.path !== b.path)
|
|
50
|
-
return a.path < b.path ? -1 : 1;
|
|
51
|
-
return a.message < b.message ? -1 : a.message > b.message ? 1 : 0;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/** True when any diagnostic is an error (drives exit code 2). */
|
|
55
|
-
export function hasErrors(diagnostics) {
|
|
56
|
-
return diagnostics.some((d) => d.level === "error");
|
|
57
|
-
}
|
|
58
|
-
/* --------------------------------------------------------------- D1 : names */
|
|
59
|
-
function checkNames(repo) {
|
|
60
|
-
const fixes = new Map();
|
|
61
|
-
for (const orphan of repo.orphans) {
|
|
62
|
-
const entity = repo.byId.get(orphan.id);
|
|
63
|
-
if (!entity || entity.kind !== orphan.kind || orphan.commentPaths.length === 0)
|
|
64
|
-
continue;
|
|
65
|
-
// The entity lives elsewhere: the stray comments belong with it (03 §3.3.1).
|
|
66
|
-
fixes.set(orphan.dirPath, orphan.commentPaths.map((path) => ({
|
|
67
|
-
op: "move",
|
|
68
|
-
from: path,
|
|
69
|
-
to: `${entity.dirPath}/comments/${path.slice(path.lastIndexOf("/") + 1)}`,
|
|
70
|
-
})));
|
|
71
|
-
}
|
|
72
|
-
return repo.problems.map((problem) => {
|
|
73
|
-
const fix = fixes.get(problem.path);
|
|
74
|
-
const orphan = repo.orphans.find((o) => o.dirPath === problem.path);
|
|
75
|
-
const entity = orphan ? repo.byId.get(orphan.id) : undefined;
|
|
76
|
-
return {
|
|
77
|
-
check: "D1",
|
|
78
|
-
level: "error",
|
|
79
|
-
path: problem.path,
|
|
80
|
-
message: fix && entity
|
|
81
|
-
? `${problem.message}; #${orphan?.id} lives at ${entity.dirPath}, so its ${fix.length} stray comment file(s) belong there`
|
|
82
|
-
: problem.message,
|
|
83
|
-
...(fix ? { fix } : {}),
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/* --------------------------------------------------------- D2 : frontmatter */
|
|
88
|
-
function checkFrontmatter(repo) {
|
|
89
|
-
const out = [];
|
|
90
|
-
for (const entity of allEntities(repo)) {
|
|
91
|
-
const problems = entity.kind === "issue" ? validateIssue(entity.parsed) : validatePr(entity.parsed);
|
|
92
|
-
for (const problem of problems) {
|
|
93
|
-
out.push({ check: "D2", level: "error", path: entity.filePath, message: problem.message });
|
|
94
|
-
}
|
|
95
|
-
for (const comment of entity.comments) {
|
|
96
|
-
for (const problem of validateComment(comment.parsed, { onPr: entity.kind === "pr" })) {
|
|
97
|
-
out.push({ check: "D2", level: "error", path: comment.path, message: problem.message });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return out;
|
|
102
|
-
}
|
|
103
|
-
/* -------------------------------------------------- D3 : ID uniqueness */
|
|
104
|
-
function collectIds(repo) {
|
|
105
|
-
const seen = new Map();
|
|
106
|
-
const entityStatuses = new Map();
|
|
107
|
-
for (const entity of allEntities(repo)) {
|
|
108
|
-
push(seen, entity.id, entity.dirPath);
|
|
109
|
-
const key = `${entity.kind}/${entity.status}`;
|
|
110
|
-
const bucket = entityStatuses.get(entity.id);
|
|
111
|
-
if (bucket)
|
|
112
|
-
bucket.add(key);
|
|
113
|
-
else
|
|
114
|
-
entityStatuses.set(entity.id, new Set([key]));
|
|
115
|
-
for (const comment of entity.comments)
|
|
116
|
-
push(seen, comment.id, comment.path);
|
|
117
|
-
}
|
|
118
|
-
const duplicates = [];
|
|
119
|
-
for (const [id, paths] of seen) {
|
|
120
|
-
if (paths.length < 2)
|
|
121
|
-
continue;
|
|
122
|
-
// A single entity living in two status directories is reported by D4.
|
|
123
|
-
if ((entityStatuses.get(id)?.size ?? 0) > 1 &&
|
|
124
|
-
paths.length === (entityStatuses.get(id)?.size ?? 0)) {
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
duplicates.push({
|
|
128
|
-
check: "D3",
|
|
129
|
-
level: "error",
|
|
130
|
-
path: paths.slice().sort()[0],
|
|
131
|
-
message: `id '${id}' is used ${paths.length} times: ${paths.slice().sort().join(", ")}`,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return { duplicates, uniqueIds: new Set(seen.keys()) };
|
|
135
|
-
}
|
|
136
|
-
function push(map, key, value) {
|
|
137
|
-
const bucket = map.get(key);
|
|
138
|
-
if (bucket)
|
|
139
|
-
bucket.push(value);
|
|
140
|
-
else
|
|
141
|
-
map.set(key, [value]);
|
|
142
|
-
}
|
|
143
|
-
/* ------------------------------------------------ D4 : one status directory */
|
|
144
|
-
function checkStatusUniqueness(repo) {
|
|
145
|
-
const byId = new Map();
|
|
146
|
-
for (const entity of allEntities(repo)) {
|
|
147
|
-
const bucket = byId.get(entity.id);
|
|
148
|
-
if (bucket)
|
|
149
|
-
bucket.push(entity);
|
|
150
|
-
else
|
|
151
|
-
byId.set(entity.id, [entity]);
|
|
152
|
-
}
|
|
153
|
-
const out = [];
|
|
154
|
-
for (const [id, records] of byId) {
|
|
155
|
-
const locations = new Set(records.map((r) => `${r.kind}/${r.status}`));
|
|
156
|
-
if (locations.size < 2)
|
|
157
|
-
continue;
|
|
158
|
-
const paths = records.map((r) => r.dirPath).sort();
|
|
159
|
-
out.push({
|
|
160
|
-
check: "D4",
|
|
161
|
-
level: "error",
|
|
162
|
-
path: paths[0],
|
|
163
|
-
message: `#${id} exists in more than one status directory: ${paths.join(", ")} (spec 03 §3.4)`,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
return out;
|
|
167
|
-
}
|
|
168
|
-
/* --------------------------------------------------------- D5 : reply-to */
|
|
169
|
-
function checkReplyTargets(repo) {
|
|
170
|
-
const out = [];
|
|
171
|
-
for (const entity of allEntities(repo)) {
|
|
172
|
-
const ids = new Set(entity.comments.map((c) => c.id));
|
|
173
|
-
for (const comment of entity.comments) {
|
|
174
|
-
if (!comment.replyTo)
|
|
175
|
-
continue;
|
|
176
|
-
if (comment.replyTo === comment.id) {
|
|
177
|
-
out.push({
|
|
178
|
-
check: "D5",
|
|
179
|
-
level: "error",
|
|
180
|
-
path: comment.path,
|
|
181
|
-
message: `'reply-to' points at the comment itself (${comment.replyTo})`,
|
|
182
|
-
});
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
if (!ids.has(comment.replyTo)) {
|
|
186
|
-
out.push({
|
|
187
|
-
check: "D5",
|
|
188
|
-
level: "error",
|
|
189
|
-
path: comment.path,
|
|
190
|
-
message: `'reply-to: ${comment.replyTo}' does not name a comment of #${entity.id}`,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return out;
|
|
196
|
-
}
|
|
197
|
-
/* ------------------------------------------------- D6 : review revisions */
|
|
198
|
-
function checkReviewRevisions(repo) {
|
|
199
|
-
const out = [];
|
|
200
|
-
for (const pr of repo.prs) {
|
|
201
|
-
const heads = new Set(readRevisions(pr.fm).map((r) => r.head));
|
|
202
|
-
for (const comment of pr.comments) {
|
|
203
|
-
const revision = comment.parsed.fm.revision;
|
|
204
|
-
if (typeof revision !== "string")
|
|
205
|
-
continue;
|
|
206
|
-
if (!heads.has(revision)) {
|
|
207
|
-
out.push({
|
|
208
|
-
check: "D6",
|
|
209
|
-
level: "error",
|
|
210
|
-
path: comment.path,
|
|
211
|
-
message: `revision ${revision.slice(0, 12)} is not a recorded revision head of #${pr.id} (spec 03 §3.5)`,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return out;
|
|
217
|
-
}
|
|
218
|
-
/* ---------------------------------------------------- D8 : dangling refs */
|
|
219
|
-
function checkDanglingRefs(repo, knownIds, commitMessages) {
|
|
220
|
-
const out = [];
|
|
221
|
-
const report = (path, ids, kind) => {
|
|
222
|
-
for (const id of ids) {
|
|
223
|
-
if (knownIds.has(id))
|
|
224
|
-
continue;
|
|
225
|
-
out.push({
|
|
226
|
-
check: "D8",
|
|
227
|
-
level: "warning",
|
|
228
|
-
path,
|
|
229
|
-
message: `${kind} reference #${id} matches no entity or comment in this tree`,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
for (const entity of allEntities(repo)) {
|
|
234
|
-
report(entity.filePath, extractProseRefs(entity.body), "prose");
|
|
235
|
-
for (const key of ["duplicate-of", "superseded-by"]) {
|
|
236
|
-
const value = entity.fm[key];
|
|
237
|
-
if (typeof value === "string" && isId(value) && !knownIds.has(value)) {
|
|
238
|
-
out.push({
|
|
239
|
-
check: "D8",
|
|
240
|
-
level: "warning",
|
|
241
|
-
path: entity.filePath,
|
|
242
|
-
message: `'${key}: ${value}' matches no entity in this tree`,
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
for (const comment of entity.comments)
|
|
247
|
-
report(comment.path, extractProseRefs(comment.body), "prose");
|
|
248
|
-
}
|
|
249
|
-
const seen = new Set();
|
|
250
|
-
for (const message of commitMessages) {
|
|
251
|
-
const { refs, closes } = extractTrailerRefs(message);
|
|
252
|
-
for (const id of [...refs, ...closes]) {
|
|
253
|
-
if (knownIds.has(id) || seen.has(id))
|
|
254
|
-
continue;
|
|
255
|
-
seen.add(id);
|
|
256
|
-
out.push({
|
|
257
|
-
check: "D8",
|
|
258
|
-
level: "warning",
|
|
259
|
-
path: "",
|
|
260
|
-
message: `commit trailer references #${id}, which matches no entity in this tree`,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return out;
|
|
265
|
-
}
|
|
266
|
-
/* ------------------------------------- D7 / D9 helpers (git-fed, pure core) */
|
|
267
|
-
/**
|
|
268
|
-
* D7: each historical `revisions` list must be a prefix of the next one.
|
|
269
|
-
* `versionsOldestFirst` holds the list as it stood in each commit that touched
|
|
270
|
-
* the file, oldest first.
|
|
271
|
-
*/
|
|
272
|
-
export function checkRevisionsAppendOnly(versionsOldestFirst) {
|
|
273
|
-
for (let i = 1; i < versionsOldestFirst.length; i++) {
|
|
274
|
-
const before = versionsOldestFirst[i - 1];
|
|
275
|
-
const after = versionsOldestFirst[i];
|
|
276
|
-
if (after.length < before.length) {
|
|
277
|
-
return {
|
|
278
|
-
ok: false,
|
|
279
|
-
index: i,
|
|
280
|
-
message: `revisions list shrank from ${before.length} to ${after.length} entries`,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
for (let j = 0; j < before.length; j++) {
|
|
284
|
-
const a = before[j];
|
|
285
|
-
const b = after[j];
|
|
286
|
-
if (a.head !== b.head || a.base !== b.base || a.date !== b.date) {
|
|
287
|
-
return { ok: false, index: i, message: `revisions[${j}] was edited after being recorded` };
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return { ok: true };
|
|
292
|
-
}
|
|
293
|
-
/** D10: is a frontmatter timestamp implausible next to the commit that added it? */
|
|
294
|
-
export function checkTimestampSkew(frontmatterIso, gitAuthoredIso, thresholdHours) {
|
|
295
|
-
const deltaHours = Math.abs(frontmatterIso.getTime() - gitAuthoredIso.getTime()) / 3_600_000;
|
|
296
|
-
return deltaHours <= thresholdHours;
|
|
297
|
-
}
|
|
298
|
-
/** Where a merged-but-unarchived pull request should be moved (check D9). */
|
|
299
|
-
export function planD9Fix(entity) {
|
|
300
|
-
const target = `${statusDir("pr", "merged")}/${entity.dirName}`;
|
|
301
|
-
return [{ op: "move", from: entity.dirPath, to: target }];
|
|
302
|
-
}
|
|
303
|
-
/** Validate a bare entity directory name, used by `doctor` on hand-made trees. */
|
|
304
|
-
export function isValidEntityDirName(name) {
|
|
305
|
-
const parsed = parseDirName(name);
|
|
306
|
-
return parsed !== null && isId(parsed.id);
|
|
307
|
-
}
|
|
308
|
-
/** Validate a bare comment filename. */
|
|
309
|
-
export function isValidCommentFileName(name) {
|
|
310
|
-
return parseCommentFileName(name) !== null;
|
|
311
|
-
}
|
|
312
|
-
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAEL,aAAa,EACb,eAAe,EACf,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAC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AAY,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,oBAAoB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;AAC7C,CAAC"}
|
package/dist/git/config.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The git configuration Navbook manages on the user's behalf.
|
|
3
|
-
*/
|
|
4
|
-
export declare const ALIAS_DEFAULT = "nav";
|
|
5
|
-
export declare const DIRECTORY_RENAMES_KEY = "merge.directoryRenames";
|
|
6
|
-
/** The `git nav` style alias: `git config --global alias.<name> '!nav'`. */
|
|
7
|
-
export declare function aliasCommand(name: string): string[];
|
|
8
|
-
export declare function readGlobal(key: string): string | null;
|
|
9
|
-
export declare function unsetGlobal(key: string): void;
|
|
10
|
-
export declare function readLocal(cwd: string, key: string): string | null;
|
|
11
|
-
export declare function setLocal(cwd: string, key: string, value: string): void;
|
|
12
|
-
export declare function unsetLocal(cwd: string, key: string): void;
|
package/dist/git/config.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The git configuration Navbook manages on the user's behalf.
|
|
3
|
-
*/
|
|
4
|
-
import { git, gitMaybe } from "./exec.js";
|
|
5
|
-
export const ALIAS_DEFAULT = "nav";
|
|
6
|
-
export const DIRECTORY_RENAMES_KEY = "merge.directoryRenames";
|
|
7
|
-
/** The `git nav` style alias: `git config --global alias.<name> '!nav'`. */
|
|
8
|
-
export function aliasCommand(name) {
|
|
9
|
-
return ["config", "--global", `alias.${name}`, "!nav"];
|
|
10
|
-
}
|
|
11
|
-
export function readGlobal(key) {
|
|
12
|
-
return gitMaybe(["config", "--global", "--get", key]);
|
|
13
|
-
}
|
|
14
|
-
export function unsetGlobal(key) {
|
|
15
|
-
// --unset fails with exit 5 when the key is already absent, which is fine.
|
|
16
|
-
gitMaybe(["config", "--global", "--unset", key]);
|
|
17
|
-
}
|
|
18
|
-
export function readLocal(cwd, key) {
|
|
19
|
-
return gitMaybe(["config", "--local", "--get", key], { cwd });
|
|
20
|
-
}
|
|
21
|
-
export function setLocal(cwd, key, value) {
|
|
22
|
-
git(["config", "--local", key, value], { cwd });
|
|
23
|
-
}
|
|
24
|
-
export function unsetLocal(cwd, key) {
|
|
25
|
-
gitMaybe(["config", "--local", "--unset", key], { cwd });
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=config.js.map
|
package/dist/git/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/git/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE9D,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,QAAQ,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,2EAA2E;IAC3E,QAAQ,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,GAAW;IAChD,OAAO,QAAQ,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,GAAW,EAAE,KAAa;IAC9D,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,GAAW;IACjD,QAAQ,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/git/exec.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The single choke point for talking to git.
|
|
3
|
-
*
|
|
4
|
-
* Navbook shells out to the `git` binary rather than linking a library, so the
|
|
5
|
-
* CLI's git behavior is definitionally the user's git (spec 05 §5.2).
|
|
6
|
-
*/
|
|
7
|
-
export interface GitResult {
|
|
8
|
-
code: number;
|
|
9
|
-
stdout: string;
|
|
10
|
-
stderr: string;
|
|
11
|
-
}
|
|
12
|
-
export interface GitOptions {
|
|
13
|
-
cwd?: string;
|
|
14
|
-
input?: string;
|
|
15
|
-
/** Extra environment entries layered over a locale-neutral base. */
|
|
16
|
-
env?: NodeJS.ProcessEnv;
|
|
17
|
-
/** Allow output larger than the default 10 MB buffer. */
|
|
18
|
-
maxBuffer?: number;
|
|
19
|
-
}
|
|
20
|
-
export declare class GitError extends Error {
|
|
21
|
-
readonly code: number;
|
|
22
|
-
readonly stderr: string;
|
|
23
|
-
readonly args: string[];
|
|
24
|
-
constructor(args: string[], result: GitResult);
|
|
25
|
-
}
|
|
26
|
-
/** Run git and return its result without throwing. */
|
|
27
|
-
export declare function gitRun(args: string[], opts?: GitOptions): GitResult;
|
|
28
|
-
/** Run git, throwing {@link GitError} on a non-zero exit. */
|
|
29
|
-
export declare function git(args: string[], opts?: GitOptions): string;
|
|
30
|
-
/** Run git and return trimmed stdout, or null when the command fails. */
|
|
31
|
-
export declare function gitMaybe(args: string[], opts?: GitOptions): string | null;
|
|
32
|
-
/** Split NUL-delimited git output into entries, dropping the trailing blank. */
|
|
33
|
-
export declare function splitNul(output: string): string[];
|
|
34
|
-
/** Split line-oriented git output, dropping the trailing blank. */
|
|
35
|
-
export declare function splitLines(output: string): string[];
|
package/dist/git/exec.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The single choke point for talking to git.
|
|
3
|
-
*
|
|
4
|
-
* Navbook shells out to the `git` binary rather than linking a library, so the
|
|
5
|
-
* CLI's git behavior is definitionally the user's git (spec 05 §5.2).
|
|
6
|
-
*/
|
|
7
|
-
import { spawnSync } from "node:child_process";
|
|
8
|
-
export class GitError extends Error {
|
|
9
|
-
code;
|
|
10
|
-
stderr;
|
|
11
|
-
args;
|
|
12
|
-
constructor(args, result) {
|
|
13
|
-
super(`git ${args.join(" ")} failed (exit ${result.code}): ${result.stderr.trim()}`);
|
|
14
|
-
this.name = "GitError";
|
|
15
|
-
this.code = result.code;
|
|
16
|
-
this.stderr = result.stderr;
|
|
17
|
-
this.args = args;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/** Run git and return its result without throwing. */
|
|
21
|
-
export function gitRun(args, opts = {}) {
|
|
22
|
-
const result = spawnSync("git", args, {
|
|
23
|
-
cwd: opts.cwd,
|
|
24
|
-
input: opts.input,
|
|
25
|
-
encoding: "utf8",
|
|
26
|
-
maxBuffer: opts.maxBuffer ?? 64 * 1024 * 1024,
|
|
27
|
-
env: { ...process.env, LC_ALL: "C", GIT_PAGER: "cat", ...opts.env },
|
|
28
|
-
});
|
|
29
|
-
if (result.error) {
|
|
30
|
-
const err = result.error;
|
|
31
|
-
if (err.code === "ENOENT") {
|
|
32
|
-
throw new Error("git was not found on PATH; Navbook requires a working git installation");
|
|
33
|
-
}
|
|
34
|
-
throw result.error;
|
|
35
|
-
}
|
|
36
|
-
return { code: result.status ?? 1, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
37
|
-
}
|
|
38
|
-
/** Run git, throwing {@link GitError} on a non-zero exit. */
|
|
39
|
-
export function git(args, opts = {}) {
|
|
40
|
-
const result = gitRun(args, opts);
|
|
41
|
-
if (result.code !== 0)
|
|
42
|
-
throw new GitError(args, result);
|
|
43
|
-
return result.stdout;
|
|
44
|
-
}
|
|
45
|
-
/** Run git and return trimmed stdout, or null when the command fails. */
|
|
46
|
-
export function gitMaybe(args, opts = {}) {
|
|
47
|
-
const result = gitRun(args, opts);
|
|
48
|
-
return result.code === 0 ? result.stdout.trim() : null;
|
|
49
|
-
}
|
|
50
|
-
/** Split NUL-delimited git output into entries, dropping the trailing blank. */
|
|
51
|
-
export function splitNul(output) {
|
|
52
|
-
return output.split("\0").filter((entry) => entry !== "");
|
|
53
|
-
}
|
|
54
|
-
/** Split line-oriented git output, dropping the trailing blank. */
|
|
55
|
-
export function splitLines(output) {
|
|
56
|
-
return output.split("\n").filter((line) => line !== "");
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=exec.js.map
|
package/dist/git/exec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/git/exec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAiB/C,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IACb,MAAM,CAAS;IACf,IAAI,CAAW;IAExB,YAAY,IAAc,EAAE,MAAiB;QAC3C,KAAK,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,MAAM,CAAC,IAAI,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrF,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,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,IAAI,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,QAAQ,CAAC,IAAc,EAAE,OAAmB,EAAE;IAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/git/history.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reading history, for the doctor checks that cannot be decided from the tree
|
|
3
|
-
* alone (D7, D9, D10) and for pinning pull-request revisions.
|
|
4
|
-
*/
|
|
5
|
-
export interface FileVersion {
|
|
6
|
-
sha: string;
|
|
7
|
-
/** The file's path in that commit, which a rename may have changed. */
|
|
8
|
-
path: string;
|
|
9
|
-
authored: Date;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Every commit that touched `path`, oldest first, following renames.
|
|
13
|
-
*
|
|
14
|
-
* `--follow` reports the path as it stood at each commit, which is what makes a
|
|
15
|
-
* `pr.md` readable across its move from `prs/open/` to `prs/merged/`.
|
|
16
|
-
*/
|
|
17
|
-
export declare function fileVersions(cwd: string, path: string): FileVersion[];
|
|
18
|
-
/** File contents at a commit, or null when the path did not exist there. */
|
|
19
|
-
export declare function blobAt(cwd: string, sha: string, path: string): string | null;
|
|
20
|
-
/** The commit that introduced `path`, following renames. */
|
|
21
|
-
export declare function addedAt(cwd: string, path: string): FileVersion | null;
|
|
22
|
-
/** True when `ancestor` is an ancestor of `descendant` (or the same commit). */
|
|
23
|
-
export declare function isAncestor(cwd: string, ancestor: string, descendant: string): boolean;
|
|
24
|
-
/** The merge base of two revisions, or null when they share no history. */
|
|
25
|
-
export declare function mergeBase(cwd: string, a: string, b: string): string | null;
|
|
26
|
-
/** True when the object exists locally; false for an unfetched commit. */
|
|
27
|
-
export declare function objectExists(cwd: string, sha: string): boolean;
|
|
28
|
-
/** Commit messages of the given revision range, newest first. */
|
|
29
|
-
export declare function commitMessages(cwd: string, range: string, limit?: number): string[];
|
|
30
|
-
/** Branch names that contain the given commit. */
|
|
31
|
-
export declare function branchesContaining(cwd: string, sha: string): string[];
|
|
32
|
-
/** Author date of a commit. */
|
|
33
|
-
export declare function authoredAt(cwd: string, sha: string): Date | null;
|
|
34
|
-
/** Resolve a revision, throwing a useful message when it does not exist. */
|
|
35
|
-
export declare function requireSha(cwd: string, rev: string): string;
|
package/dist/git/history.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reading history, for the doctor checks that cannot be decided from the tree
|
|
3
|
-
* alone (D7, D9, D10) and for pinning pull-request revisions.
|
|
4
|
-
*/
|
|
5
|
-
import { git, gitMaybe, gitRun, splitLines } from "./exec.js";
|
|
6
|
-
/** ASCII SOH/STX: separators that cannot occur in a commit message or path. */
|
|
7
|
-
const RECORD_SEPARATOR = "\u0001";
|
|
8
|
-
const FIELD_SEPARATOR = "\u0002";
|
|
9
|
-
/**
|
|
10
|
-
* Every commit that touched `path`, oldest first, following renames.
|
|
11
|
-
*
|
|
12
|
-
* `--follow` reports the path as it stood at each commit, which is what makes a
|
|
13
|
-
* `pr.md` readable across its move from `prs/open/` to `prs/merged/`.
|
|
14
|
-
*/
|
|
15
|
-
export function fileVersions(cwd, path) {
|
|
16
|
-
const output = gitMaybe(["log", "--follow", "--name-only", "--format=%x01%H%x02%aI", "--", path], { cwd });
|
|
17
|
-
if (output === null)
|
|
18
|
-
return [];
|
|
19
|
-
const versions = [];
|
|
20
|
-
for (const record of output.split(RECORD_SEPARATOR)) {
|
|
21
|
-
if (record.trim() === "")
|
|
22
|
-
continue;
|
|
23
|
-
const [header, ...rest] = record.split("\n");
|
|
24
|
-
const [sha, authored] = (header ?? "").split(FIELD_SEPARATOR);
|
|
25
|
-
if (!sha || !authored)
|
|
26
|
-
continue;
|
|
27
|
-
const names = rest.filter((line) => line.trim() !== "");
|
|
28
|
-
const date = new Date(authored);
|
|
29
|
-
if (Number.isNaN(date.getTime()))
|
|
30
|
-
continue;
|
|
31
|
-
versions.push({ sha, path: names[0] ?? path, authored: date });
|
|
32
|
-
}
|
|
33
|
-
return versions.reverse();
|
|
34
|
-
}
|
|
35
|
-
/** File contents at a commit, or null when the path did not exist there. */
|
|
36
|
-
export function blobAt(cwd, sha, path) {
|
|
37
|
-
const result = gitRun(["show", `${sha}:${path}`], { cwd });
|
|
38
|
-
return result.code === 0 ? result.stdout : null;
|
|
39
|
-
}
|
|
40
|
-
/** The commit that introduced `path`, following renames. */
|
|
41
|
-
export function addedAt(cwd, path) {
|
|
42
|
-
return fileVersions(cwd, path)[0] ?? null;
|
|
43
|
-
}
|
|
44
|
-
/** True when `ancestor` is an ancestor of `descendant` (or the same commit). */
|
|
45
|
-
export function isAncestor(cwd, ancestor, descendant) {
|
|
46
|
-
return gitRun(["merge-base", "--is-ancestor", ancestor, descendant], { cwd }).code === 0;
|
|
47
|
-
}
|
|
48
|
-
/** The merge base of two revisions, or null when they share no history. */
|
|
49
|
-
export function mergeBase(cwd, a, b) {
|
|
50
|
-
return gitMaybe(["merge-base", a, b], { cwd });
|
|
51
|
-
}
|
|
52
|
-
/** True when the object exists locally; false for an unfetched commit. */
|
|
53
|
-
export function objectExists(cwd, sha) {
|
|
54
|
-
return gitRun(["cat-file", "-e", `${sha}^{commit}`], { cwd }).code === 0;
|
|
55
|
-
}
|
|
56
|
-
/** Commit messages of the given revision range, newest first. */
|
|
57
|
-
export function commitMessages(cwd, range, limit = 100) {
|
|
58
|
-
const output = gitMaybe(["log", "--format=%B%x00", "-n", String(limit), range], { cwd });
|
|
59
|
-
if (output === null)
|
|
60
|
-
return [];
|
|
61
|
-
return output.split("\0").filter((message) => message.trim() !== "");
|
|
62
|
-
}
|
|
63
|
-
/** Branch names that contain the given commit. */
|
|
64
|
-
export function branchesContaining(cwd, sha) {
|
|
65
|
-
const output = gitMaybe(["branch", "--all", "--format=%(refname:short)", "--contains", sha], {
|
|
66
|
-
cwd,
|
|
67
|
-
});
|
|
68
|
-
return output === null ? [] : splitLines(output);
|
|
69
|
-
}
|
|
70
|
-
/** Author date of a commit. */
|
|
71
|
-
export function authoredAt(cwd, sha) {
|
|
72
|
-
const value = gitMaybe(["show", "-s", "--format=%aI", sha], { cwd });
|
|
73
|
-
if (value === null)
|
|
74
|
-
return null;
|
|
75
|
-
const date = new Date(value);
|
|
76
|
-
return Number.isNaN(date.getTime()) ? null : date;
|
|
77
|
-
}
|
|
78
|
-
/** Resolve a revision, throwing a useful message when it does not exist. */
|
|
79
|
-
export function requireSha(cwd, rev) {
|
|
80
|
-
return git(["rev-parse", "--verify", `${rev}^{commit}`], { cwd }).trim();
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=history.js.map
|
package/dist/git/history.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/git/history.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE9D,+EAA+E;AAC/E,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AW,EAAE,UAAU,EAAE,GAAG,GAAG,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3E,CAAC"}
|
package/dist/git/index-ops.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Index and commit operations.
|
|
3
|
-
*/
|
|
4
|
-
import type { Trailer } from "../core/ops.ts";
|
|
5
|
-
/** Repository-relative paths currently staged in the index. */
|
|
6
|
-
export declare function stagedPaths(cwd: string): string[];
|
|
7
|
-
/** Contents of a staged file, or null when it is not in the index. */
|
|
8
|
-
export declare function stagedContent(cwd: string, path: string): string | null;
|
|
9
|
-
/** Repository-relative paths of every file in the index. */
|
|
10
|
-
export declare function indexPaths(cwd: string): string[];
|
|
11
|
-
/** Stage the given paths, including deletions. */
|
|
12
|
-
export declare function add(cwd: string, paths: readonly string[]): void;
|
|
13
|
-
/** Move a tracked path, staging the rename. */
|
|
14
|
-
export declare function move(cwd: string, from: string, to: string): void;
|
|
15
|
-
/** Compose a commit message from a subject and its trailers. */
|
|
16
|
-
export declare function composeMessage(subject: string, trailers: readonly Trailer[]): string;
|
|
17
|
-
/** Create a commit from what is currently staged. */
|
|
18
|
-
export declare function commit(cwd: string, message: string, opts?: {
|
|
19
|
-
allowEmpty?: boolean;
|
|
20
|
-
}): string;
|