architecture-harness 0.16.0 → 0.17.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/package.json +8 -3
- package/src/cli/bash-command-guard.mjs +25 -10
- package/src/cli/bash-command-guard.test.mjs +30 -0
- package/src/cli/bash-edit-guard.mjs +28 -7
- package/src/cli/bash-edit-guard.test.mjs +24 -0
- package/src/cli/check-registries.test.mjs +181 -0
- package/src/cli/check.mjs +130 -9
- package/src/cli/cli.test.mjs +215 -2
- package/src/cli/contract-history.mjs +46 -0
- package/src/cli/contract-history.test.mjs +118 -0
- package/src/cli/controller-guard.mjs +73 -0
- package/src/cli/controller-guard.test.mjs +119 -0
- package/src/cli/dispatch-guard.mjs +9 -3
- package/src/cli/dispatch-reminder.mjs +19 -11
- package/src/cli/dispatch-reminder.test.mjs +32 -0
- package/src/cli/dispatch.mjs +3 -0
- package/src/cli/dispatch.test.mjs +15 -1
- package/src/cli/doctor.mjs +2 -1
- package/src/cli/explore-guard.mjs +2 -2
- package/src/cli/gh-merge-command.mjs +228 -0
- package/src/cli/gh-merge-command.test.mjs +273 -0
- package/src/cli/gh-run.mjs +30 -0
- package/src/cli/gh-run.test.mjs +22 -0
- package/src/cli/git-hooks.test.mjs +28 -0
- package/src/cli/git-read.mjs +42 -0
- package/src/cli/git-read.test.mjs +94 -0
- package/src/cli/init.mjs +7 -3
- package/src/cli/issue-gate.mjs +169 -0
- package/src/cli/issue-gate.test.mjs +234 -0
- package/src/cli/ledger.mjs +136 -0
- package/src/cli/ledger.test.mjs +127 -0
- package/src/cli/merge-guard.mjs +193 -0
- package/src/cli/merge-guard.test.mjs +328 -0
- package/src/cli/plan-check.mjs +151 -0
- package/src/cli/plan-check.test.mjs +143 -0
- package/src/cli/plan-stop.mjs +101 -0
- package/src/cli/plan-stop.test.mjs +136 -0
- package/src/cli/plugin-agents.test.mjs +96 -8
- package/src/cli/pr-check.mjs +17 -5
- package/src/cli/pr-check.test.mjs +85 -4
- package/src/cli/prose.mjs +192 -0
- package/src/cli/prose.test.mjs +248 -0
- package/src/cli/qc.mjs +16 -0
- package/src/cli/registry-history.mjs +1 -1
- package/src/cli/report-stash.mjs +69 -0
- package/src/cli/report-stash.test.mjs +71 -0
- package/src/cli/report-stop.mjs +256 -0
- package/src/cli/report-stop.test.mjs +432 -0
- package/src/cli/shell-command.mjs +81 -6
- package/src/cli/shell-command.test.mjs +101 -1
- package/src/cli/task-gate.mjs +157 -0
- package/src/cli/task-gate.test.mjs +421 -0
- package/src/cli/workflow-hooks.test.mjs +72 -0
- package/src/cli/workflow-place.mjs +143 -0
- package/src/cli/workflow-place.test.mjs +146 -0
- package/src/cli/workflow-settings.mjs +77 -0
- package/src/cli/workflow-settings.test.mjs +79 -0
- package/src/cli/worktree.mjs +1 -1
- package/src/cli/worktree.test.mjs +19 -2
- package/src/config.mjs +84 -3
- package/src/config.test.mjs +38 -3
- package/src/descriptions.mjs +5 -1
- package/src/eslint/index.mjs +2 -0
- package/src/eslint/jsx.mjs +57 -0
- package/src/eslint/preset.mjs +32 -6
- package/src/eslint/preset.test.mjs +60 -0
- package/src/eslint/rules/durable-idempotency-key.mjs +26 -0
- package/src/eslint/rules/ime-safe-key.mjs +1 -50
- package/src/eslint/rules/mutation-control-pending.mjs +128 -0
- package/src/eslint/rules/no-supersession-trail.mjs +8 -4
- package/src/eslint/rules/registry-literal.mjs +36 -2
- package/src/eslint/rules.test.mjs +153 -0
- package/src/gates/call-args.mjs +90 -0
- package/src/gates/call-args.test.mjs +21 -0
- package/src/gates/config-floor.mjs +41 -20
- package/src/gates/config-floor.test.mjs +71 -1
- package/src/gates/contract-idempotency.mjs +103 -0
- package/src/gates/contract-idempotency.test.mjs +276 -0
- package/src/gates/contract-operations.mjs +120 -0
- package/src/gates/contract-operations.test.mjs +275 -0
- package/src/gates/contract-routes.mjs +82 -0
- package/src/gates/contract-routes.test.mjs +210 -0
- package/src/gates/registry-literal.mjs +79 -15
- package/src/gates/registry-literal.test.mjs +89 -0
- package/src/gates/saga-key.mjs +253 -0
- package/src/gates/saga-key.test.mjs +322 -0
- package/src/gates/scrub.mjs +108 -0
- package/src/gates/scrub.test.mjs +29 -0
- package/src/gates/tenant-isolation-test.mjs +80 -0
- package/src/gates/tenant-isolation-test.test.mjs +129 -0
- package/src/gates/tenant-predicate.mjs +644 -91
- package/src/gates/tenant-predicate.test.mjs +662 -1
- package/src/prose-lines.mjs +49 -0
- package/src/prose-lines.test.mjs +63 -0
- package/src/registries.mjs +89 -0
- package/src/registries.test.mjs +44 -0
- package/src/vale-style.test.mjs +158 -0
- package/templates/docs/enforcement.md +26 -2
- package/templates/github/workflows/ci.yml +18 -1
- package/templates/quality-thresholds.json +1 -1
- package/templates/vale/.vale.ini +7 -0
- package/templates/vale/styles/Qc/AndOr.yml +7 -0
- package/templates/vale/styles/Qc/InOrderTo.yml +6 -0
- package/templates/vale/styles/Qc/Latin.yml +9 -0
- package/templates/vale/styles/Qc/PassiveVoice.yml +21 -0
- package/templates/vale/styles/Qc/Please.yml +6 -0
- package/templates/vale/styles/Qc/Progress.yml +9 -0
- package/templates/vale/styles/Qc/SentenceLength.yml +6 -0
- package/templates/vale/styles/Qc/Utilize.yml +10 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { strict as assert } from "node:assert";
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import { ghApiMerges, ghMerges } from "./gh-merge-command.mjs";
|
|
7
|
+
import { powershellSegments } from "./powershell-command.mjs";
|
|
8
|
+
import { segmentsOf } from "./shell-command.mjs";
|
|
9
|
+
|
|
10
|
+
test("a POSIX merge carries its sha, PR, repository, and GH_* prefix, and never a token", () => {
|
|
11
|
+
assert.deepEqual(
|
|
12
|
+
ghMerges("GH_CONFIG_DIR=~/.config/gh-personal GH_TOKEN=x gh pr merge 60 -R o/r --squash --match-head-commit abc1234", segmentsOf),
|
|
13
|
+
[{ sha: "abc1234", repo: "o/r", selector: "60", auto: false, env: { GH_CONFIG_DIR: "~/.config/gh-personal" } }],
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("inline flag values, an exported setting, and a merge with no PR named", () => {
|
|
18
|
+
assert.deepEqual(ghMerges("gh pr merge --repo=o/r --match-head-commit=abc1234 61", segmentsOf), [
|
|
19
|
+
{ sha: "abc1234", repo: "o/r", selector: "61", auto: false, env: {} },
|
|
20
|
+
]);
|
|
21
|
+
assert.deepEqual(ghMerges("export GH_HOST=ghe.example.com && gh pr merge --auto -s", segmentsOf), [
|
|
22
|
+
{ sha: null, repo: null, selector: null, auto: true, env: { GH_HOST: "ghe.example.com" } },
|
|
23
|
+
]);
|
|
24
|
+
assert.deepEqual(ghMerges('gh pr merge -b "Closes #1" -t subject 62 --match-head-commit abc1234', segmentsOf)[0].selector, "62");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("a PowerShell merge reads the $env: settings before it", () => {
|
|
28
|
+
assert.deepEqual(ghMerges(String.raw`$env:GH_CONFIG_DIR = "C:\gh"; gh pr merge 63 --match-head-commit abc1234`, powershellSegments), [
|
|
29
|
+
{ sha: "abc1234", repo: null, selector: "63", auto: false, env: { GH_CONFIG_DIR: String.raw`C:\gh` } },
|
|
30
|
+
]);
|
|
31
|
+
assert.deepEqual(ghMerges(String.raw`$env:gh_host="ghe.example.com"; gh.exe pr merge 64`, powershellSegments)[0].env, { GH_HOST: "ghe.example.com" });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("a nested shell's merge is found, and what is no merge is left alone", () => {
|
|
35
|
+
assert.equal(ghMerges(`bash -c "gh pr merge 65"`, segmentsOf).length, 1);
|
|
36
|
+
assert.equal(ghMerges(`pwsh -Command "gh pr merge 66 --match-head-commit abc1234"`, powershellSegments)[0].sha, "abc1234");
|
|
37
|
+
for (const command of ["gh pr view 60", "gh pr merge 60 --disable-auto", "git merge feat/x", "echo gh pr merge"]) {
|
|
38
|
+
assert.deepEqual(ghMerges(command, segmentsOf), [], command);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("a gh api call to a PR's merge endpoint is found, in each spelling, and no other gh api call is", () => {
|
|
43
|
+
const endpoints = (command, parse = segmentsOf) => ghApiMerges(command, parse).map((call) => call.endpoint);
|
|
44
|
+
assert.deepEqual(endpoints("gh api -X PUT repos/o/r/pulls/60/merge -f merge_method=squash"), ["repos/o/r/pulls/60/merge"]);
|
|
45
|
+
assert.deepEqual(endpoints("gh api --method=PUT /repos/{owner}/{repo}/pulls/61/merge"), ["/repos/{owner}/{repo}/pulls/61/merge"]);
|
|
46
|
+
assert.deepEqual(endpoints(`bash -c "gh api repos/o/r/pulls/62/merge -X PUT"`), ["repos/o/r/pulls/62/merge"]);
|
|
47
|
+
assert.deepEqual(endpoints(String.raw`gh.exe api repos/o/r/pulls/63/merge -X PUT`, powershellSegments), ["repos/o/r/pulls/63/merge"]);
|
|
48
|
+
for (const command of [
|
|
49
|
+
"gh api repos/o/r/pulls/60",
|
|
50
|
+
"gh api repos/o/r/pulls/60/comments",
|
|
51
|
+
"gh api repos/o/r/issues/60 -f body=x/pulls/1/merge",
|
|
52
|
+
"gh pr merge 60",
|
|
53
|
+
"echo gh api repos/o/r/pulls/60/merge",
|
|
54
|
+
]) {
|
|
55
|
+
assert.deepEqual(endpoints(command), [], command);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const MUTATION = "mutation { mergePullRequest(input: {pullRequestId: \"X\"}) { clientMutationId } }";
|
|
60
|
+
|
|
61
|
+
test("a mutation word in any argument is found, whatever the spelling of the GraphQL URL", () => {
|
|
62
|
+
for (const url of ["graphql", "/graphql", "https://api.github.com/graphql", "https://ghe.example.com/api/graphql", "graphql/"]) {
|
|
63
|
+
assert.deepEqual(ghApiMerges(`gh api ${url} -f query='${MUTATION}'`, segmentsOf).map((call) => call.endpoint), [url], url);
|
|
64
|
+
}
|
|
65
|
+
assert.equal(ghApiMerges(`gh api -X POST graphql -F query='${MUTATION}'`, segmentsOf).length, 1);
|
|
66
|
+
assert.equal(ghApiMerges(`gh api graphql -f query='${MUTATION}'`, powershellSegments).length, 1);
|
|
67
|
+
assert.equal(ghApiMerges(`gh api graphql -f query='query { viewer { login } }'`, segmentsOf).length, 0);
|
|
68
|
+
assert.equal(ghApiMerges("gh api https://api.github.com/graphql -f query='query { viewer { login } }'", segmentsOf).length, 0);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("a query file the call reads is searched for the mutation, and a file the guard cannot read fails closed", (t) => {
|
|
72
|
+
const dir = mkdtempSync(path.join(os.tmpdir(), "qc-gh-api-"));
|
|
73
|
+
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
74
|
+
writeFileSync(path.join(dir, "merge.graphql"), MUTATION);
|
|
75
|
+
writeFileSync(path.join(dir, "viewer.graphql"), "query { viewer { login } }");
|
|
76
|
+
writeFileSync(path.join(dir, "body.json"), JSON.stringify({ query: MUTATION }));
|
|
77
|
+
const found = (command) => ghApiMerges(command, segmentsOf, { cwd: dir });
|
|
78
|
+
assert.equal(found("gh api https://api.github.com/graphql -F query=@merge.graphql").length, 1);
|
|
79
|
+
assert.equal(found("gh api graphql --field=query=@merge.graphql").length, 1);
|
|
80
|
+
assert.equal(found("gh api graphql --input body.json").length, 1);
|
|
81
|
+
assert.equal(found(`gh api graphql -F query=@${path.join(dir, "merge.graphql").replaceAll("\\", "/")}`).length, 1);
|
|
82
|
+
assert.equal(found("gh api graphql -Fquery=@merge.graphql").length, 1, "an attached short flag carries its value");
|
|
83
|
+
assert.equal(found("gh api graphql -F=query=@merge.graphql").length, 1);
|
|
84
|
+
assert.equal(found("gh api graphql -fquery=@merge.graphql").length, 0, "-f reads no file");
|
|
85
|
+
assert.equal(found("gh api graphql -Fquery=@missing.graphql")[0].unreadable, "missing.graphql");
|
|
86
|
+
assert.equal(found("gh api graphql -iFquery=@merge.graphql").length, 1, "a cluster of short flags ends in -F");
|
|
87
|
+
assert.equal(found("gh api graphql -i -F query=@merge.graphql").length, 1);
|
|
88
|
+
assert.equal(found("gh api graphql -iF query=@merge.graphql").length, 1, "a cluster that ends in -F takes the next argument");
|
|
89
|
+
assert.equal(found("gh api graphql -fFquery=@merge.graphql").length, 0, "-f takes the rest of the word as its value");
|
|
90
|
+
assert.equal(found("gh api graphql -iFquery=@viewer.graphql").length, 0);
|
|
91
|
+
assert.equal(found("gh api graphql --field=query=@missing.graphql")[0].unreadable, "missing.graphql");
|
|
92
|
+
assert.equal(found("gh api graphql -Fquery=@-")[0].unreadable, "-");
|
|
93
|
+
assert.equal(found("gh api graphql -iFquery=@missing.graphql")[0].unreadable, "missing.graphql");
|
|
94
|
+
assert.equal(found("gh api graphql -Fquery=@viewer.graphql").length, 0);
|
|
95
|
+
assert.equal(found("gh api graphql -F query=@viewer.graphql").length, 0);
|
|
96
|
+
assert.equal(found("gh api graphql -f query=@merge.graphql").length, 0, "-f sends the text as written and reads no file");
|
|
97
|
+
const [unreadable] = found("gh api graphql -F query=@missing.graphql");
|
|
98
|
+
assert.equal(unreadable.endpoint, "graphql");
|
|
99
|
+
assert.equal(unreadable.unreadable, "missing.graphql");
|
|
100
|
+
assert.equal(found("gh api graphql -F query=@-")[0].unreadable, "-");
|
|
101
|
+
assert.equal(found("gh api graphql --input -")[0].unreadable, "-");
|
|
102
|
+
// A call to another endpoint never fails closed on a file it cannot read.
|
|
103
|
+
assert.equal(found("gh api repos/o/r/issues/1/comments -F body=@notes.txt").length, 0);
|
|
104
|
+
assert.equal(found("gh api repos/o/r/issues/1/comments -F body=@-").length, 0);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("the repository of a merge comes from a PR URL, GH_REPO, an attached -R, or a cluster that ends in -R", () => {
|
|
108
|
+
const repoOf = (command, parse = segmentsOf) => ghMerges(command, parse)[0].repo;
|
|
109
|
+
assert.equal(repoOf("gh pr merge https://github.com/o/r/pull/5 --match-head-commit abc1234"), "o/r");
|
|
110
|
+
assert.equal(repoOf("gh pr merge https://ghe.example.com/o/r/pull/5/files"), "o/r");
|
|
111
|
+
assert.equal(repoOf("GH_REPO=o/r gh pr merge 5"), "o/r");
|
|
112
|
+
assert.equal(repoOf("export GH_REPO=o/r && gh pr merge 5"), "o/r");
|
|
113
|
+
assert.equal(repoOf(String.raw`$env:GH_REPO = "o/r"; gh pr merge 5`, powershellSegments), "o/r");
|
|
114
|
+
assert.equal(repoOf("gh pr merge 5 -Ro/r"), "o/r");
|
|
115
|
+
assert.equal(repoOf("gh pr merge 5 -R=o/r"), "o/r");
|
|
116
|
+
assert.equal(repoOf("gh pr merge 5 -sRo/r"), "o/r");
|
|
117
|
+
assert.equal(repoOf("gh pr merge 5 -sR o/r"), "o/r");
|
|
118
|
+
assert.equal(repoOf("gh pr merge 5 --repo=o/r"), "o/r");
|
|
119
|
+
assert.equal(repoOf("GH_REPO=x/y gh pr merge 5 -R o/r"), "o/r", "an explicit -R beats GH_REPO");
|
|
120
|
+
assert.equal(repoOf("gh pr merge https://github.com/o/r/pull/5 -R x/y"), "o/r", "a PR URL beats -R");
|
|
121
|
+
assert.equal(repoOf("gh pr merge 5"), null);
|
|
122
|
+
assert.equal(repoOf("gh pr merge 5 -bRo/r"), null, "-b takes the rest of the word as its value");
|
|
123
|
+
assert.deepEqual(ghMerges("GH_REPO=o/r gh pr merge 5", segmentsOf)[0].env, {}, "GH_REPO is not kept as a setting");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("a mutation search skips a call whose endpoint is a repos/ REST path", (t) => {
|
|
127
|
+
const dir = mkdtempSync(path.join(os.tmpdir(), "qc-gh-api-rest-"));
|
|
128
|
+
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
129
|
+
writeFileSync(path.join(dir, "review.md"), "The bypass is the mergePullRequest mutation.");
|
|
130
|
+
const found = (command) => ghApiMerges(command, segmentsOf, { cwd: dir });
|
|
131
|
+
assert.equal(found("gh api repos/o/r/issues/64/comments -F body=@review.md").length, 0);
|
|
132
|
+
assert.equal(found("gh api repos/o/r/issues/64/comments -f body='see mergePullRequest'").length, 0);
|
|
133
|
+
assert.equal(found("gh api https://api.github.com/repos/o/r/issues/64/comments -F body=@review.md").length, 0);
|
|
134
|
+
assert.equal(found("gh api -X POST -H 'Accept: x' /repos/o/r/issues/64/comments -iFbody=@review.md").length, 0);
|
|
135
|
+
// The REST merge endpoint stays refused by its own rule.
|
|
136
|
+
assert.equal(found("gh api -X PUT repos/o/r/pulls/64/merge -F body=@review.md").length, 1);
|
|
137
|
+
// A word that only looks like a path, as the value of a flag, is no endpoint.
|
|
138
|
+
assert.equal(found("gh api -H repos/x graphql -f query='mutation { mergePullRequest(input: {}) { clientMutationId } }'").length, 1);
|
|
139
|
+
assert.equal(found("gh api graphql -F query=@review.md -f x=repos/o/r").length, 1);
|
|
140
|
+
assert.equal(found("gh api -q repos/x graphql -F query=@review.md").length, 1);
|
|
141
|
+
// A path that climbs out of repos/ or ends at graphql is searched.
|
|
142
|
+
const mutation = "mutation { mergePullRequest }";
|
|
143
|
+
for (const endpoint of ["repos/../graphql", "/repos/o/r/../../graphql", "repos/o/r/%2e%2e/graphql", "https://api.github.com/repos/../graphql", "repos/o/r/graphql", "repos/o/r/../x"]) {
|
|
144
|
+
assert.equal(found(`gh api ${endpoint} -f query='${mutation}'`).length, 1, endpoint);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test("each wrapper spelling is seen as a merge", () => {
|
|
149
|
+
for (const command of [
|
|
150
|
+
`bash -lc 'gh pr merge 60'`,
|
|
151
|
+
`bash -ic "gh pr merge 60"`,
|
|
152
|
+
`bash -lic 'gh pr merge 60'`,
|
|
153
|
+
`sh -c 'gh pr merge 60'`,
|
|
154
|
+
`zsh -lc 'gh pr merge 60'`,
|
|
155
|
+
`env gh pr merge 60`,
|
|
156
|
+
`env -i GH_HOST=x gh pr merge 60`,
|
|
157
|
+
`sudo gh pr merge 60`,
|
|
158
|
+
`sudo -u ci gh pr merge 60`,
|
|
159
|
+
`command gh pr merge 60`,
|
|
160
|
+
`time gh pr merge 60`,
|
|
161
|
+
`nohup gh pr merge 60`,
|
|
162
|
+
`timeout 30 gh pr merge 60`,
|
|
163
|
+
`env bash -lc 'sudo gh pr merge 60'`,
|
|
164
|
+
`eval 'gh pr merge 60'`,
|
|
165
|
+
`eval gh pr merge 60`,
|
|
166
|
+
`eval "cd x; gh pr merge 60"`,
|
|
167
|
+
`if true; then gh pr merge 60; fi`,
|
|
168
|
+
`if gh pr merge 60; then echo ok; fi`,
|
|
169
|
+
"if true\nthen\n gh pr merge 60\nfi",
|
|
170
|
+
`for n in 60; do gh pr merge $n; done`,
|
|
171
|
+
`{ gh pr merge 60; }`,
|
|
172
|
+
`bash -c 'if true; then gh pr merge 60; fi'`,
|
|
173
|
+
`gh pr -R o/r merge 60`,
|
|
174
|
+
`gh pr --repo o/r merge 60`,
|
|
175
|
+
`gh -R o/r pr merge 60`,
|
|
176
|
+
]) {
|
|
177
|
+
assert.equal(ghMerges(command, segmentsOf).length, 1, command);
|
|
178
|
+
}
|
|
179
|
+
assert.equal(ghMerges(String.raw`pwsh -c "gh pr merge 60"`, powershellSegments).length, 1);
|
|
180
|
+
assert.equal(ghMerges(String.raw`pwsh -NoProfile -ExecutionPolicy Bypass -Command "gh pr merge 60"`, powershellSegments).length, 1);
|
|
181
|
+
assert.equal(ghMerges(String.raw`if ($true) { gh pr merge 60 }`, powershellSegments).length, 1);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("a wrapped gh api merge is seen as one", () => {
|
|
185
|
+
const endpoints = (command) => ghApiMerges(command, segmentsOf).map((call) => call.endpoint);
|
|
186
|
+
for (const command of [
|
|
187
|
+
`bash -lc 'gh api -X PUT repos/o/r/pulls/60/merge'`,
|
|
188
|
+
`env gh api -X PUT repos/o/r/pulls/60/merge`,
|
|
189
|
+
`sudo gh api -X PUT repos/o/r/pulls/60/merge`,
|
|
190
|
+
`eval 'gh api -X PUT repos/o/r/pulls/60/merge'`,
|
|
191
|
+
`if true; then gh api -X PUT repos/o/r/pulls/60/merge; fi`,
|
|
192
|
+
`gh -R o/r api -X PUT repos/o/r/pulls/60/merge`,
|
|
193
|
+
]) {
|
|
194
|
+
assert.deepEqual(endpoints(command), ["repos/o/r/pulls/60/merge"], command);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("the repo flag before the verb is the merge's repo", () => {
|
|
199
|
+
const repo = (command) => ghMerges(command, segmentsOf)[0].repo;
|
|
200
|
+
assert.equal(repo("gh pr -R o/r merge 60"), "o/r");
|
|
201
|
+
assert.equal(repo("gh pr --repo o/r merge 60"), "o/r");
|
|
202
|
+
assert.equal(repo("gh pr --repo=o/r merge 60"), "o/r");
|
|
203
|
+
assert.equal(repo("gh pr -Ro/r merge 60"), "o/r");
|
|
204
|
+
assert.equal(repo("gh pr -R=o/r merge 60"), "o/r");
|
|
205
|
+
assert.equal(repo("gh -R o/r pr merge 60"), "o/r");
|
|
206
|
+
// The flag written last wins, as it does in gh, and a PR URL wins over both.
|
|
207
|
+
assert.equal(repo("gh pr -R a/b merge 60 -R o/r"), "o/r");
|
|
208
|
+
assert.equal(repo("gh pr -R a/b merge https://github.com/o/r/pull/60"), "o/r");
|
|
209
|
+
assert.equal(repo("GH_REPO=x/y gh pr -R o/r merge 60"), "o/r");
|
|
210
|
+
assert.equal(repo("GH_REPO=o/r gh pr merge 60"), "o/r");
|
|
211
|
+
assert.equal(repo("env GH_REPO=o/r gh pr merge 60"), "o/r");
|
|
212
|
+
assert.equal(repo("bash -lc 'gh pr -R o/r merge 60'"), "o/r");
|
|
213
|
+
assert.equal(ghMerges("gh pr -R o/r merge 60 --match-head-commit abc1234", segmentsOf)[0].sha, "abc1234");
|
|
214
|
+
assert.equal(ghMerges("gh pr -R o/r merge 60", segmentsOf)[0].selector, "60");
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test("the settings a wrapper or a nested shell's prefix makes reach the merge", () => {
|
|
218
|
+
const env = (command) => ghMerges(command, segmentsOf)[0].env;
|
|
219
|
+
assert.deepEqual(env("env GH_CONFIG_DIR=/c GH_TOKEN=x gh pr merge 60"), { GH_CONFIG_DIR: "/c" });
|
|
220
|
+
assert.deepEqual(env("sudo GH_HOST=h gh pr merge 60"), { GH_HOST: "h" });
|
|
221
|
+
assert.deepEqual(env("GH_CONFIG_DIR=/c bash -lc 'gh pr merge 60'"), { GH_CONFIG_DIR: "/c" });
|
|
222
|
+
assert.deepEqual(env("GH_CONFIG_DIR=/c eval 'gh pr merge 60'"), { GH_CONFIG_DIR: "/c" });
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("a wrapped gh that is no merge is not a merge", () => {
|
|
226
|
+
for (const command of [
|
|
227
|
+
"env gh pr view 60",
|
|
228
|
+
"sudo gh pr -R o/r view 60",
|
|
229
|
+
"bash -lc 'gh pr view 60'",
|
|
230
|
+
"eval 'gh pr merge 60 --disable-auto'",
|
|
231
|
+
"if true; then gh pr list; fi",
|
|
232
|
+
"env echo gh pr merge 60",
|
|
233
|
+
"command -v gh",
|
|
234
|
+
"bash -lc 'echo gh pr merge 60'",
|
|
235
|
+
"gh pr -R o/r comment 60",
|
|
236
|
+
"gh -R o/r pr view merge",
|
|
237
|
+
]) {
|
|
238
|
+
assert.deepEqual(ghMerges(command, segmentsOf), [], command);
|
|
239
|
+
}
|
|
240
|
+
// Known gap: `xargs` runs its arguments as a command, and the parser does not follow it.
|
|
241
|
+
assert.deepEqual(ghMerges("echo 60 | xargs gh pr merge", segmentsOf), []);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test("exec, nice, ionice, stdbuf, setsid, doas, builtin, and ! wrap a merge that is still seen", () => {
|
|
245
|
+
for (const command of [
|
|
246
|
+
"exec gh pr merge 5",
|
|
247
|
+
"nice -n 5 gh pr merge 5",
|
|
248
|
+
"ionice -c 3 gh pr merge 5",
|
|
249
|
+
"stdbuf -o0 gh pr merge 5",
|
|
250
|
+
"setsid gh pr merge 5",
|
|
251
|
+
"doas gh pr merge 5",
|
|
252
|
+
"builtin exec gh pr merge 5",
|
|
253
|
+
"bash -c 'exec gh pr merge 5'",
|
|
254
|
+
"! gh pr merge 5",
|
|
255
|
+
"if ! gh pr merge 5; then echo failed; fi",
|
|
256
|
+
"nice -n 5 gh api -X PUT repos/o/r/pulls/5/merge",
|
|
257
|
+
]) {
|
|
258
|
+
assert.equal(ghMerges(command, segmentsOf).length + ghApiMerges(command, segmentsOf).length, 1, command);
|
|
259
|
+
}
|
|
260
|
+
assert.deepEqual(ghMerges("nice -n 5 gh pr view 5", segmentsOf), []);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("only -R and --repo name the repository before the verb, not a longer flag that starts with them", () => {
|
|
264
|
+
const repo = (command) => ghMerges(command, segmentsOf)[0]?.repo;
|
|
265
|
+
assert.equal(repo("gh pr --repoX o/r merge 60"), undefined);
|
|
266
|
+
assert.equal(repo("gh pr --repoX merge 60"), null);
|
|
267
|
+
assert.equal(repo("gh pr --repository merge 60"), null);
|
|
268
|
+
assert.equal(repo("gh pr --repo o/r merge 60"), "o/r");
|
|
269
|
+
assert.equal(repo("gh pr --repo=o/r merge 60"), "o/r");
|
|
270
|
+
assert.equal(repo("gh pr -R o/r merge 60"), "o/r");
|
|
271
|
+
assert.equal(repo("gh pr -Ro/r merge 60"), "o/r");
|
|
272
|
+
assert.equal(repo("gh pr -R=o/r merge 60"), "o/r");
|
|
273
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// A fragment that runs one gh call for a workflow hook. The caller passes the GH_* settings the user's
|
|
2
|
+
// own command made, so the hook reads with the account that command used.
|
|
3
|
+
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
|
|
8
|
+
const GH_TIMEOUT_MS = 20_000;
|
|
9
|
+
|
|
10
|
+
/** Expands a leading `~`, `~/`, or `~\` in each value, as a shell does for an assignment. */
|
|
11
|
+
export function expandHome(env) {
|
|
12
|
+
return Object.fromEntries(
|
|
13
|
+
Object.entries(env ?? {}).map(([name, value]) => [
|
|
14
|
+
name,
|
|
15
|
+
typeof value === "string" && (value === "~" || value.startsWith("~/") || value.startsWith("~\\")) ? path.join(os.homedir(), value.slice(1)) : value,
|
|
16
|
+
]),
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** @returns gh's stdout on exit 0, or null when gh fails, times out, or is not installed. */
|
|
21
|
+
export function runGh(args, { cwd = process.cwd(), env = {} } = {}) {
|
|
22
|
+
const result = spawnSync("gh", args, {
|
|
23
|
+
cwd,
|
|
24
|
+
encoding: "utf8",
|
|
25
|
+
windowsHide: true,
|
|
26
|
+
timeout: GH_TIMEOUT_MS,
|
|
27
|
+
env: { ...process.env, ...expandHome(env) },
|
|
28
|
+
});
|
|
29
|
+
return result.status === 0 ? (result.stdout ?? "") : null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { strict as assert } from "node:assert";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { test } from "node:test";
|
|
5
|
+
import { expandHome, runGh } from "./gh-run.mjs";
|
|
6
|
+
|
|
7
|
+
test("expandHome expands a leading ~ the way the shell would, and leaves every other value", () => {
|
|
8
|
+
assert.deepEqual(expandHome({ GH_CONFIG_DIR: "~/.config/gh-personal", GH_HOST: "ghe.example.com" }), {
|
|
9
|
+
GH_CONFIG_DIR: path.join(os.homedir(), "/.config/gh-personal"),
|
|
10
|
+
GH_HOST: "ghe.example.com",
|
|
11
|
+
});
|
|
12
|
+
assert.deepEqual(expandHome({ A: "~\\.config\\gh", B: "~" }), {
|
|
13
|
+
A: path.join(os.homedir(), "\\.config\\gh"),
|
|
14
|
+
B: os.homedir(),
|
|
15
|
+
});
|
|
16
|
+
assert.deepEqual(expandHome({ A: "~other/x", B: "C:/gh" }), { A: "~other/x", B: "C:/gh" });
|
|
17
|
+
assert.deepEqual(expandHome(undefined), {});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("runGh answers null when gh fails or is missing", () => {
|
|
21
|
+
assert.equal(runGh(["no-such-command-for-qc"]), null);
|
|
22
|
+
});
|
|
@@ -5,6 +5,7 @@ import os from "node:os";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { test } from "node:test";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { defaults, requiredHooks } from "../config.mjs";
|
|
8
9
|
import { hookDrift } from "./git-hooks.mjs";
|
|
9
10
|
|
|
10
11
|
const TEMPLATES = fileURLToPath(new URL("../../templates/githooks/", import.meta.url));
|
|
@@ -83,3 +84,30 @@ test("qc doctor fails on hook drift, and passes the kit's template", async (t) =
|
|
|
83
84
|
copyFileSync(path.join(TEMPLATES, "pre-commit"), path.join(r.root, ".githooks", "pre-commit"));
|
|
84
85
|
assert.equal(await runDoctor({ root: r.root, hooks: { required: REQUIRED } }), 0);
|
|
85
86
|
});
|
|
87
|
+
|
|
88
|
+
const withConventional = (conventional) => ({ ...defaults, commitMessage: { ...defaults.commitMessage, conventional } });
|
|
89
|
+
|
|
90
|
+
function strictFolder(t, names) {
|
|
91
|
+
const r = repo(t);
|
|
92
|
+
mkdirSync(path.join(r.root, ".githooks"));
|
|
93
|
+
for (const name of names) copyFileSync(path.join(TEMPLATES, name), path.join(r.root, ".githooks", name));
|
|
94
|
+
return r;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
test("conventional on and no commit-msg hook fails hooks (strict folder)", (t) => {
|
|
98
|
+
const r = strictFolder(t, ["pre-commit", "pre-push"]);
|
|
99
|
+
const { problems } = hookDrift(r.root, requiredHooks(withConventional(true)));
|
|
100
|
+
assert.equal(problems.length, 1);
|
|
101
|
+
assert.equal(problems[0].path, ".githooks/commit-msg");
|
|
102
|
+
assert.match(problems[0].detail, /commit-msg is missing/);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("conventional on and the template commit-msg hook passes", (t) => {
|
|
106
|
+
const r = strictFolder(t, ["pre-commit", "pre-push", "commit-msg"]);
|
|
107
|
+
assert.deepEqual(hookDrift(r.root, requiredHooks(withConventional(true))).problems, []);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("conventional false and no commit-msg hook passes", (t) => {
|
|
111
|
+
const r = strictFolder(t, ["pre-commit", "pre-push"]);
|
|
112
|
+
assert.deepEqual(hookDrift(r.root, requiredHooks(withConventional(false))).problems, []);
|
|
113
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// A fragment of the git reads the workflow checks share. Each read returns null or an empty list when git
|
|
2
|
+
// fails, so a check that cannot read the repository decides on what it has.
|
|
3
|
+
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
|
|
6
|
+
export { keyOf as pathKey } from "./worktree.mjs";
|
|
7
|
+
|
|
8
|
+
const GIT_TIMEOUT_MS = 10_000;
|
|
9
|
+
|
|
10
|
+
/** @returns git's trimmed stdout, or null on a non-zero exit or after `timeoutMs`. */
|
|
11
|
+
export function gitOutWithin(timeoutMs, cwd, ...args) {
|
|
12
|
+
const result = spawnSync("git", args, { cwd, encoding: "utf8", windowsHide: true, timeout: timeoutMs });
|
|
13
|
+
return result.status === 0 ? (result.stdout ?? "").trim() : null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @returns git's trimmed stdout, or null on a non-zero exit or a timeout. */
|
|
17
|
+
export const gitOut = (cwd, ...args) => gitOutWithin(GIT_TIMEOUT_MS, cwd, ...args);
|
|
18
|
+
|
|
19
|
+
/** @returns the full sha that `ref` names as a commit, or null when the repository holds none. */
|
|
20
|
+
export const commitOf = (cwd, ref) => gitOut(cwd, "rev-parse", "--verify", "--quiet", `${ref}^{commit}`);
|
|
21
|
+
|
|
22
|
+
/** @returns the branch checked out at `dir`, or null on a detached head. */
|
|
23
|
+
export const branchAt = (dir) => gitOut(dir, "branch", "--show-current") || null;
|
|
24
|
+
|
|
25
|
+
/** @returns the local branches whose head is `sha`, in ref order. */
|
|
26
|
+
export const branchesAt = (cwd, sha) =>
|
|
27
|
+
(gitOut(cwd, "for-each-ref", "--points-at", sha, "--format=%(refname:short)", "refs/heads") ?? "").split(/\r?\n/).filter(Boolean);
|
|
28
|
+
|
|
29
|
+
/** @returns each linked worktree of the repository at `root`, with its branch and head; the primary checkout is left out. */
|
|
30
|
+
export function linkedWorktrees(root) {
|
|
31
|
+
const out = gitOut(root, "worktree", "list", "--porcelain");
|
|
32
|
+
if (out === null) return [];
|
|
33
|
+
return out
|
|
34
|
+
.split(/\r?\n[ \t]*\r?\n/)
|
|
35
|
+
.map((block) => {
|
|
36
|
+
const lines = block.split(/\r?\n/);
|
|
37
|
+
const field = (name) => lines.find((line) => line.startsWith(`${name} `))?.slice(name.length + 1) ?? null;
|
|
38
|
+
return { path: field("worktree"), branch: field("branch")?.replace(/^refs\/heads\//, "") ?? null, head: field("HEAD") };
|
|
39
|
+
})
|
|
40
|
+
.filter((entry) => entry.path)
|
|
41
|
+
.slice(1);
|
|
42
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { strict as assert } from "node:assert";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { test } from "node:test";
|
|
7
|
+
import { branchAt, branchesAt, commitOf, gitOut, gitOutWithin, linkedWorktrees, pathKey } from "./git-read.mjs";
|
|
8
|
+
|
|
9
|
+
const git = (cwd, ...args) => execFileSync("git", args, { cwd, stdio: "pipe", encoding: "utf8" }).trim();
|
|
10
|
+
|
|
11
|
+
// A timed-out git call can leave a child that holds the folder for a moment, so a removal retries.
|
|
12
|
+
// rmSync's own retries do not cover the EPERM Windows raises while the child still holds the folder, so a
|
|
13
|
+
// failed removal waits and tries again.
|
|
14
|
+
function removeTree(dir) {
|
|
15
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
16
|
+
try {
|
|
17
|
+
rmSync(dir, { recursive: true, force: true, maxRetries: 20, retryDelay: 250 });
|
|
18
|
+
return;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (attempt >= 20) throw error;
|
|
21
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 250);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function repo(t) {
|
|
27
|
+
const base = realpathSync.native(mkdtempSync(path.join(os.tmpdir(), "qc-git-read-")));
|
|
28
|
+
t.after(() => removeTree(base));
|
|
29
|
+
const main = path.join(base, "main");
|
|
30
|
+
git(base, "init", "-q", "-b", "main", main);
|
|
31
|
+
for (const [key, value] of [["user.name", "qc"], ["user.email", "qc@example.com"], ["commit.gpgsign", "false"]]) {
|
|
32
|
+
git(main, "config", key, value);
|
|
33
|
+
}
|
|
34
|
+
writeFileSync(path.join(main, "a.txt"), "a\n");
|
|
35
|
+
git(main, "add", ".");
|
|
36
|
+
git(main, "commit", "-q", "-m", "init");
|
|
37
|
+
const linked = path.join(base, "linked");
|
|
38
|
+
git(main, "worktree", "add", "-q", "-b", "feat/1-x", linked);
|
|
39
|
+
return { main, linked, head: git(main, "rev-parse", "HEAD") };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
test("commitOf resolves a short or upper-case sha, and refuses one the repository lacks", (t) => {
|
|
43
|
+
const { main, head } = repo(t);
|
|
44
|
+
assert.equal(commitOf(main, head.slice(0, 7)), head);
|
|
45
|
+
assert.equal(commitOf(main, head.slice(0, 9).toUpperCase()), head);
|
|
46
|
+
assert.equal(commitOf(main, "deadbee"), null);
|
|
47
|
+
assert.equal(gitOut(main, "no-such-subcommand"), null);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("branchAt names the branch, and a detached head has none", (t) => {
|
|
51
|
+
const { main, linked } = repo(t);
|
|
52
|
+
assert.equal(branchAt(linked), "feat/1-x");
|
|
53
|
+
assert.equal(branchAt(main), "main");
|
|
54
|
+
git(linked, "checkout", "-q", "--detach");
|
|
55
|
+
assert.equal(branchAt(linked), null);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("branchesAt lists every local branch whose head is the sha", (t) => {
|
|
59
|
+
const { main, head } = repo(t);
|
|
60
|
+
assert.deepEqual(branchesAt(main, head), ["feat/1-x", "main"]);
|
|
61
|
+
assert.deepEqual(branchesAt(main, "0".repeat(40)), []);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("linkedWorktrees leaves out the primary checkout and names each branch and head", (t) => {
|
|
65
|
+
const { main, linked, head } = repo(t);
|
|
66
|
+
const found = linkedWorktrees(main);
|
|
67
|
+
assert.equal(found.length, 1);
|
|
68
|
+
assert.equal(pathKey(found[0].path), pathKey(linked));
|
|
69
|
+
assert.equal(found[0].branch, "feat/1-x");
|
|
70
|
+
assert.equal(found[0].head, head);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("pathKey spells one folder one way", (t) => {
|
|
74
|
+
const { linked } = repo(t);
|
|
75
|
+
assert.equal(pathKey(linked.replaceAll("\\", "/")), pathKey(linked));
|
|
76
|
+
if (process.platform === "win32") assert.equal(pathKey(linked.toUpperCase()), pathKey(linked));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("linkedWorktrees run from a linked worktree still leaves out the primary checkout", (t) => {
|
|
80
|
+
const { main, linked } = repo(t);
|
|
81
|
+
const found = linkedWorktrees(linked);
|
|
82
|
+
assert.equal(found.length, 1);
|
|
83
|
+
assert.equal(pathKey(found[0].path), pathKey(linked));
|
|
84
|
+
assert.notEqual(pathKey(found[0].path), pathKey(main));
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("a git call that outlives its timeout answers null", (t) => {
|
|
88
|
+
const { main } = repo(t);
|
|
89
|
+
const slow = ["-c", 'alias.slow=!node -e "setTimeout(() => {}, 3000)"', "slow"];
|
|
90
|
+
const started = Date.now();
|
|
91
|
+
assert.equal(gitOutWithin(200, main, ...slow), null);
|
|
92
|
+
assert.ok(Date.now() - started < 2500);
|
|
93
|
+
assert.equal(gitOutWithin(10_000, main, "rev-parse", "--is-inside-work-tree"), "true");
|
|
94
|
+
});
|
package/src/cli/init.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { copyFile, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
6
6
|
import { withEnforcementMap } from "../enforcement-map.mjs";
|
|
7
|
-
import { existsSync } from "node:fs";
|
|
7
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
|
|
@@ -27,8 +27,12 @@ const FILES = [
|
|
|
27
27
|
["docs/glossary.md", "docs/glossary.md"],
|
|
28
28
|
["docs/ui.md", "docs/ui.md"],
|
|
29
29
|
["githooks/pre-commit", ".githooks/pre-commit"],
|
|
30
|
+
["githooks/commit-msg", ".githooks/commit-msg"],
|
|
30
31
|
["githooks/pre-push", ".githooks/pre-push"],
|
|
31
32
|
["github/workflows/ci.yml", ".github/workflows/ci.yml"],
|
|
33
|
+
// The prose style `qc prose` hands to Vale: one config and one file per rule.
|
|
34
|
+
["vale/.vale.ini", ".vale/.vale.ini"],
|
|
35
|
+
...readdirSync(path.join(templates, "vale/styles/Qc")).map((rule) => [`vale/styles/Qc/${rule}`, `.vale/styles/Qc/${rule}`]),
|
|
32
36
|
];
|
|
33
37
|
|
|
34
38
|
// The enforcement map is filled in on the way out, so a rule added to the kit cannot ship a
|
|
@@ -71,7 +75,7 @@ export async function runInit(config, args = []) {
|
|
|
71
75
|
results.push(await copyTemplate(path.join(templates, source), path.join(config.root, target), force, config));
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
for (const name of ["pre-commit", "pre-push"]) {
|
|
78
|
+
for (const name of ["pre-commit", "commit-msg", "pre-push"]) {
|
|
75
79
|
const hook = path.join(config.root, ".githooks", name);
|
|
76
80
|
if (existsSync(hook)) await writeFile(hook, await readFile(hook, "utf8"), { mode: 0o755 });
|
|
77
81
|
}
|
|
@@ -93,6 +97,6 @@ Next:
|
|
|
93
97
|
2. Edit docs/glossary.md and the per-surface table in docs/performance.md.
|
|
94
98
|
3. Point qc.config.json at your layout if it differs from the reference. \`qc config\`
|
|
95
99
|
prints what is in force — featureRoots matching nothing is a failed check, not a pass.
|
|
96
|
-
4. \`qc install-hooks\` to bind the pre-commit and pre-push hooks.
|
|
100
|
+
4. \`qc install-hooks\` to bind the pre-commit, commit-msg and pre-push hooks.
|
|
97
101
|
5. \`qc feature <domain-name>\` to scaffold the first slice, then \`qc check\`.`);
|
|
98
102
|
}
|