@webpieces/pr-gate 0.4.974 → 0.4.976
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 +6 -6
- package/src/scripts/commands/await-checks-command.d.ts +6 -3
- package/src/scripts/commands/await-checks-command.js +17 -12
- package/src/scripts/commands/await-checks-command.js.map +1 -1
- package/src/scripts/commands/await-reviews-command.d.ts +1 -1
- package/src/scripts/commands/await-reviews-command.js +3 -3
- package/src/scripts/commands/await-reviews-command.js.map +1 -1
- package/src/scripts/commands/check-pr-command.d.ts +3 -1
- package/src/scripts/commands/check-pr-command.js +12 -9
- package/src/scripts/commands/check-pr-command.js.map +1 -1
- package/src/scripts/commands/finish-push-dev-command.js +3 -4
- package/src/scripts/commands/finish-push-dev-command.js.map +1 -1
- package/src/scripts/commands/finish-update-command.js +1 -1
- package/src/scripts/commands/finish-update-command.js.map +1 -1
- package/src/scripts/commands/finish-upsert-pr-command.d.ts +4 -1
- package/src/scripts/commands/finish-upsert-pr-command.js +65 -62
- package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/human-post-pr-command.d.ts +8 -6
- package/src/scripts/commands/human-post-pr-command.js +32 -31
- package/src/scripts/commands/human-post-pr-command.js.map +1 -1
- package/src/scripts/commands/land-pr-command.d.ts +5 -1
- package/src/scripts/commands/land-pr-command.js +36 -22
- package/src/scripts/commands/land-pr-command.js.map +1 -1
- package/src/scripts/commands/main-checkout.d.ts +4 -1
- package/src/scripts/commands/main-checkout.js +22 -22
- package/src/scripts/commands/main-checkout.js.map +1 -1
- package/src/scripts/commands/push-dev-command.js +28 -29
- package/src/scripts/commands/push-dev-command.js.map +1 -1
- package/src/scripts/commands/review-upsert-pr-command.js +9 -9
- package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/start-update-command.d.ts +1 -1
- package/src/scripts/commands/start-update-command.js +3 -3
- package/src/scripts/commands/start-update-command.js.map +1 -1
- package/src/scripts/commands/start-upsert-pr-command.js +4 -4
- package/src/scripts/commands/start-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/sync-main-command.js +2 -2
- package/src/scripts/commands/sync-main-command.js.map +1 -1
- package/src/scripts/commands/upsert-hotfix-pr-command.d.ts +6 -4
- package/src/scripts/commands/upsert-hotfix-pr-command.js +46 -43
- package/src/scripts/commands/upsert-hotfix-pr-command.js.map +1 -1
- package/src/scripts/commands/working-tree-gate.d.ts +4 -1
- package/src/scripts/commands/working-tree-gate.js +14 -11
- package/src/scripts/commands/working-tree-gate.js.map +1 -1
- package/src/scripts/commands/write-review-command.js +4 -6
- package/src/scripts/commands/write-review-command.js.map +1 -1
- package/src/scripts/commands/write-review-fixes-command.js +3 -4
- package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
- package/src/scripts/git-finishUpsertPr.js +2 -2
- package/src/scripts/git-finishUpsertPr.js.map +1 -1
- package/src/scripts/git-gatherInfo.js +6 -7
- package/src/scripts/git-gatherInfo.js.map +1 -1
- package/src/scripts/pr-gate-container.d.ts +9 -0
- package/src/scripts/pr-gate-container.js +19 -0
- package/src/scripts/pr-gate-container.js.map +1 -0
- package/src/scripts/workflow/await-loop.d.ts +1 -1
- package/src/scripts/workflow/await-loop.js +1 -1
- package/src/scripts/workflow/await-loop.js.map +1 -1
- package/src/scripts/workflow/build-affected.js +1 -1
- package/src/scripts/workflow/build-affected.js.map +1 -1
- package/src/scripts/workflow/build-artifact-gate.d.ts +1 -1
- package/src/scripts/workflow/build-artifact-gate.js +3 -3
- package/src/scripts/workflow/build-artifact-gate.js.map +1 -1
- package/src/scripts/workflow/build-gate-log.d.ts +9 -6
- package/src/scripts/workflow/build-gate-log.js +34 -40
- package/src/scripts/workflow/build-gate-log.js.map +1 -1
- package/src/scripts/workflow/checklist-scanner.d.ts +1 -1
- package/src/scripts/workflow/checklist-scanner.js +8 -8
- package/src/scripts/workflow/checklist-scanner.js.map +1 -1
- package/src/scripts/workflow/checklist-scope-hasher.d.ts +1 -1
- package/src/scripts/workflow/checklist-scope-hasher.js +2 -2
- package/src/scripts/workflow/checklist-scope-hasher.js.map +1 -1
- package/src/scripts/workflow/dev-deploy-refs.d.ts +5 -5
- package/src/scripts/workflow/dev-deploy-refs.js +8 -8
- package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
- package/src/scripts/workflow/dev-resolve-runner.d.ts +3 -3
- package/src/scripts/workflow/dev-resolve-runner.js +30 -30
- package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
- package/src/scripts/workflow/diff-basis.d.ts +4 -2
- package/src/scripts/workflow/diff-basis.js +18 -15
- package/src/scripts/workflow/diff-basis.js.map +1 -1
- package/src/scripts/workflow/diff-materializer.d.ts +5 -3
- package/src/scripts/workflow/diff-materializer.js +18 -15
- package/src/scripts/workflow/diff-materializer.js.map +1 -1
- package/src/scripts/workflow/gated-pr-publisher.d.ts +8 -6
- package/src/scripts/workflow/gated-pr-publisher.js +23 -22
- package/src/scripts/workflow/gated-pr-publisher.js.map +1 -1
- package/src/scripts/workflow/generated-artifact-registry.d.ts +4 -2
- package/src/scripts/workflow/generated-artifact-registry.js +11 -8
- package/src/scripts/workflow/generated-artifact-registry.js.map +1 -1
- package/src/scripts/workflow/git-exec.d.ts +22 -12
- package/src/scripts/workflow/git-exec.js +45 -29
- package/src/scripts/workflow/git-exec.js.map +1 -1
- package/src/scripts/workflow/git-findForkPoint.d.ts +6 -2
- package/src/scripts/workflow/git-findForkPoint.js +31 -23
- package/src/scripts/workflow/git-findForkPoint.js.map +1 -1
- package/src/scripts/workflow/git-readAiBranchName.d.ts +4 -2
- package/src/scripts/workflow/git-readAiBranchName.js +8 -5
- package/src/scripts/workflow/git-readAiBranchName.js.map +1 -1
- package/src/scripts/workflow/hotfix-pr-publisher.d.ts +4 -3
- package/src/scripts/workflow/hotfix-pr-publisher.js +7 -6
- package/src/scripts/workflow/hotfix-pr-publisher.js.map +1 -1
- package/src/scripts/workflow/landed-tree-resolver.d.ts +4 -2
- package/src/scripts/workflow/landed-tree-resolver.js +11 -8
- package/src/scripts/workflow/landed-tree-resolver.js.map +1 -1
- package/src/scripts/workflow/landed-worktree-reaper.d.ts +4 -2
- package/src/scripts/workflow/landed-worktree-reaper.js +12 -9
- package/src/scripts/workflow/landed-worktree-reaper.js.map +1 -1
- package/src/scripts/workflow/merge-end.d.ts +2 -2
- package/src/scripts/workflow/merge-end.js +22 -24
- package/src/scripts/workflow/merge-end.js.map +1 -1
- package/src/scripts/workflow/merge-start.d.ts +5 -1
- package/src/scripts/workflow/merge-start.js +56 -49
- package/src/scripts/workflow/merge-start.js.map +1 -1
- package/src/scripts/workflow/open-pr-check.d.ts +4 -2
- package/src/scripts/workflow/open-pr-check.js +11 -8
- package/src/scripts/workflow/open-pr-check.js.map +1 -1
- package/src/scripts/workflow/pr-comment-upserter.d.ts +5 -3
- package/src/scripts/workflow/pr-comment-upserter.js +15 -14
- package/src/scripts/workflow/pr-comment-upserter.js.map +1 -1
- package/src/scripts/workflow/pr-merger.d.ts +8 -5
- package/src/scripts/workflow/pr-merger.js +32 -27
- package/src/scripts/workflow/pr-merger.js.map +1 -1
- package/src/scripts/workflow/provenance-enforcer.d.ts +4 -2
- package/src/scripts/workflow/provenance-enforcer.js +19 -17
- package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
- package/src/scripts/workflow/review-round-state.d.ts +7 -6
- package/src/scripts/workflow/review-round-state.js +33 -38
- package/src/scripts/workflow/review-round-state.js.map +1 -1
- package/src/scripts/workflow/run-update.js +1 -1
- package/src/scripts/workflow/run-update.js.map +1 -1
- package/src/scripts/workflow/squash-settings-enforcer.d.ts +6 -3
- package/src/scripts/workflow/squash-settings-enforcer.js +19 -14
- package/src/scripts/workflow/squash-settings-enforcer.js.map +1 -1
- package/src/scripts/wp-await-checks.js +2 -2
- package/src/scripts/wp-await-checks.js.map +1 -1
- package/src/scripts/wp-await-reviews.js +2 -2
- package/src/scripts/wp-await-reviews.js.map +1 -1
- package/src/scripts/wp-build.js +2 -2
- package/src/scripts/wp-build.js.map +1 -1
- package/src/scripts/wp-check-pr.js +2 -2
- package/src/scripts/wp-check-pr.js.map +1 -1
- package/src/scripts/wp-cleanup.js +2 -2
- package/src/scripts/wp-cleanup.js.map +1 -1
- package/src/scripts/wp-finish-push-dev.js +2 -2
- package/src/scripts/wp-finish-push-dev.js.map +1 -1
- package/src/scripts/wp-finish-update.js +2 -2
- package/src/scripts/wp-finish-update.js.map +1 -1
- package/src/scripts/wp-human-post-pr.js +2 -2
- package/src/scripts/wp-human-post-pr.js.map +1 -1
- package/src/scripts/wp-land-pr.js +2 -2
- package/src/scripts/wp-land-pr.js.map +1 -1
- package/src/scripts/wp-push-dev.js +2 -2
- package/src/scripts/wp-push-dev.js.map +1 -1
- package/src/scripts/wp-reap-worktree.js +2 -2
- package/src/scripts/wp-reap-worktree.js.map +1 -1
- package/src/scripts/wp-review-upsert-pr.js +2 -2
- package/src/scripts/wp-review-upsert-pr.js.map +1 -1
- package/src/scripts/wp-start-update.js +2 -2
- package/src/scripts/wp-start-update.js.map +1 -1
- package/src/scripts/wp-start-upsert-pr.js +2 -2
- package/src/scripts/wp-start-upsert-pr.js.map +1 -1
- package/src/scripts/wp-sync-main.js +2 -2
- package/src/scripts/wp-sync-main.js.map +1 -1
- package/src/scripts/wp-upsert-hotfix-pr.js +2 -2
- package/src/scripts/wp-upsert-hotfix-pr.js.map +1 -1
- package/src/scripts/wp-write-review-fixes.js +2 -2
- package/src/scripts/wp-write-review-fixes.js.map +1 -1
- package/src/scripts/wp-write-review.js +2 -2
- package/src/scripts/wp-write-review.js.map +1 -1
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UpsertHotfixPrCommand = exports.HotfixPrRef = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
7
6
|
const path = tslib_1.__importStar(require("path"));
|
|
8
7
|
const repo_workflow_core_1 = require("@webpieces/repo-workflow-core");
|
|
9
8
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
9
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
10
10
|
const inversify_1 = require("inversify");
|
|
11
11
|
const git_readAiBranchName_1 = require("../workflow/git-readAiBranchName");
|
|
12
12
|
const git_exec_1 = require("../workflow/git-exec");
|
|
@@ -70,8 +70,9 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
|
|
|
70
70
|
commentUpserter;
|
|
71
71
|
squashSettings;
|
|
72
72
|
gateTokenService;
|
|
73
|
+
processes;
|
|
73
74
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
74
|
-
constructor(repoRootFinder, branchIdentity, aiBranchName, gitExec, reviewJsonService, buildAffected, buildArtifactGate, mergeState, checklistScanner, publisher, dashboard, authorIdentity, checklistComment, commentUpserter, squashSettings, gateTokenService) {
|
|
75
|
+
constructor(repoRootFinder, branchIdentity, aiBranchName, gitExec, reviewJsonService, buildAffected, buildArtifactGate, mergeState, checklistScanner, publisher, dashboard, authorIdentity, checklistComment, commentUpserter, squashSettings, gateTokenService, processes) {
|
|
75
76
|
this.repoRootFinder = repoRootFinder;
|
|
76
77
|
this.branchIdentity = branchIdentity;
|
|
77
78
|
this.aiBranchName = aiBranchName;
|
|
@@ -88,6 +89,7 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
|
|
|
88
89
|
this.commentUpserter = commentUpserter;
|
|
89
90
|
this.squashSettings = squashSettings;
|
|
90
91
|
this.gateTokenService = gateTokenService;
|
|
92
|
+
this.processes = processes;
|
|
91
93
|
}
|
|
92
94
|
async run() {
|
|
93
95
|
const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());
|
|
@@ -95,26 +97,26 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
|
|
|
95
97
|
// FIRST, before any write: a non-hotfix branch gets nothing from this command, not even a template.
|
|
96
98
|
this.assertHotfixBranch(branch);
|
|
97
99
|
(0, rules_config_1.writeTemplate)(repoRoot, 'webpieces.git-workflow.md');
|
|
98
|
-
this.gitExec.assertCleanTree(repoRoot);
|
|
99
|
-
this.assertNoUnvalidatedMerge(repoRoot);
|
|
100
|
-
const featureName = this.aiBranchName.getFeatureName();
|
|
100
|
+
await this.gitExec.assertCleanTree(repoRoot);
|
|
101
|
+
await this.assertNoUnvalidatedMerge(repoRoot);
|
|
102
|
+
const featureName = await this.aiBranchName.getFeatureName();
|
|
101
103
|
const summaryPath = this.reviewJsonService.summaryJsonPath(repoRoot, featureName);
|
|
102
104
|
// Throws InformAiError carrying the path and the schema when summary.json is missing or invalid.
|
|
103
105
|
const summary = this.reviewJsonService.loadSummaryJson(summaryPath, [], '', {}, hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND);
|
|
104
106
|
// FAIL FAST on a hand-written closing reference (issue #1310); renderPrBody re-judges the final body.
|
|
105
107
|
new issue_references_1.IssueReferences().assertNoStrayClosingReferences(summary.summary, summary.addressesIssues, hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND);
|
|
106
108
|
// origin/main is READ (the build's merge-base and the dashboard's fork point) — never merged.
|
|
107
|
-
this.fetchMain(repoRoot);
|
|
108
|
-
const headBefore = this.headSha(repoRoot);
|
|
109
|
+
await this.fetchMain(repoRoot);
|
|
110
|
+
const headBefore = await this.headSha(repoRoot);
|
|
109
111
|
await this.buildAffected.runBuildGate(repoRoot, new build_affected_1.BuildGateOptions('🛠️ Hotfix build gate (hotfix-ci: build + test only)', hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND, 'Hotfix build failed — nothing was pushed and no PR was created or updated.', build_gate_log_1.FINISH_STAGE));
|
|
110
|
-
this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);
|
|
111
|
-
this.gitExec.assertCleanTree(repoRoot);
|
|
112
|
-
if (this.headSha(repoRoot) !== headBefore) {
|
|
112
|
+
await this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);
|
|
113
|
+
await this.gitExec.assertCleanTree(repoRoot);
|
|
114
|
+
if (await this.headSha(repoRoot) !== headBefore) {
|
|
113
115
|
throw new rules_config_1.CliExitError(1, `❌ HEAD moved while the hotfix build ran, so the build does not cover the commit that would be pushed. Nothing was pushed. Re-run ${hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND}.`);
|
|
114
116
|
}
|
|
115
|
-
const ref = this.publish(repoRoot, branch, summary, headBefore);
|
|
116
|
-
this.postComments(repoRoot, featureName, ref, summary);
|
|
117
|
-
this.squashSettings.ensure();
|
|
117
|
+
const ref = await this.publish(repoRoot, branch, summary, headBefore);
|
|
118
|
+
await this.postComments(repoRoot, featureName, ref, summary);
|
|
119
|
+
await this.squashSettings.ensure();
|
|
118
120
|
const archived = this.reviewJsonService.archiveSummaryJson(summaryPath);
|
|
119
121
|
if (archived !== '')
|
|
120
122
|
process.stdout.write(` archived this run's summary.json → ${archived} (audit only) ✓\n`);
|
|
@@ -128,8 +130,8 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
|
|
|
128
130
|
' pnpm wp-start-upsert-pr\n pnpm wp-review-upsert-pr\n pnpm wp-finish-upsert-pr');
|
|
129
131
|
}
|
|
130
132
|
// A hotfix flow never STARTS a merge, but a branch somebody ran wp-start-update on can carry one.
|
|
131
|
-
assertNoUnvalidatedMerge(repoRoot) {
|
|
132
|
-
const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());
|
|
133
|
+
async assertNoUnvalidatedMerge(repoRoot) {
|
|
134
|
+
const home = this.mergeState.mergeDirFor(repoRoot, await this.aiBranchName.getFeatureName());
|
|
133
135
|
const active = this.mergeState.findActiveMergeRunDir(home);
|
|
134
136
|
const marker = active === null ? null : this.mergeState.readMergeMarker(active);
|
|
135
137
|
if (marker === null || marker.validated)
|
|
@@ -139,50 +141,50 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
|
|
|
139
141
|
`commits, then re-run ${hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND}. Nothing was pushed.`);
|
|
140
142
|
}
|
|
141
143
|
/** Body before push (GatedPrPublisher's ordering), fast-forward push, then create or edit — never merge. */
|
|
142
|
-
publish(repoRoot, branch, summary, headSha) {
|
|
144
|
+
async publish(repoRoot, branch, summary, headSha) {
|
|
143
145
|
const config = this.prGateConfig(repoRoot);
|
|
144
|
-
const input = this.dashboardInput(repoRoot, summary, config);
|
|
146
|
+
const input = await this.dashboardInput(repoRoot, summary, config);
|
|
145
147
|
const tokenSuffix = this.tokenSuffix(config.gateSalt, headSha);
|
|
146
|
-
const initial = this.prRef(branch);
|
|
148
|
+
const initial = await this.prRef(branch);
|
|
147
149
|
const body = this.dashboard.renderPrBody(input, initial.url) + tokenSuffix;
|
|
148
150
|
for (const warning of new issue_references_1.IssueReferences().closeWarnings(summary.addressesIssues))
|
|
149
151
|
process.stdout.write(`${warning}\n`);
|
|
150
|
-
const bodyFile = path.join(this.reviewJsonService.prDirFor(repoRoot, this.aiBranchName.getFeatureName()), 'pr-body.md');
|
|
152
|
+
const bodyFile = path.join(this.reviewJsonService.prDirFor(repoRoot, await this.aiBranchName.getFeatureName()), 'pr-body.md');
|
|
151
153
|
fs.mkdirSync(path.dirname(bodyFile), { recursive: true });
|
|
152
154
|
fs.writeFileSync(bodyFile, body + '\n');
|
|
153
155
|
process.stdout.write('\n' + SEP + '📋 Hotfix PR (bannered audit, never auto-merged)\n' + SEP + '\n');
|
|
154
|
-
const published = this.publisher.publish(branch, this.titleFrom(summary, branch), bodyFile, hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND);
|
|
156
|
+
const published = await this.publisher.publish(branch, this.titleFrom(summary, branch), bodyFile, hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND);
|
|
155
157
|
if (published.createFailed) {
|
|
156
158
|
throw new rules_config_1.CliExitError(1, `❌ gh pr create failed after the push. The rendered body is in ${bodyFile}; summary.json was kept. Re-run ${hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND}.`);
|
|
157
159
|
}
|
|
158
|
-
const ref = this.prRef(branch);
|
|
160
|
+
const ref = await this.prRef(branch);
|
|
159
161
|
const resolved = new HotfixPrRef(ref.number !== '' ? ref.number : published.number, ref.url);
|
|
160
162
|
// A brand-new PR had no URL to self-link until `gh pr create` returned one.
|
|
161
163
|
const finalBody = this.dashboard.renderPrBody(input, resolved.url) + tokenSuffix;
|
|
162
164
|
if (finalBody !== body && resolved.number !== '') {
|
|
163
165
|
fs.writeFileSync(bodyFile, finalBody + '\n');
|
|
164
|
-
if (!this.editPrBody(resolved.number, bodyFile)) {
|
|
166
|
+
if (!(await this.editPrBody(resolved.number, bodyFile))) {
|
|
165
167
|
process.stderr.write(`⚠️ Could not add the PR's own link to its description (non-fatal — the PR and the gate token are up).\n`);
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
return resolved;
|
|
169
171
|
}
|
|
170
|
-
dashboardInput(repoRoot, summary, config) {
|
|
171
|
-
const forkPoint = this.git(repoRoot, ['merge-base', 'origin/main', 'HEAD']);
|
|
172
|
-
const featureHead = this.git(repoRoot, ['rev-parse', 'HEAD']);
|
|
173
|
-
const mainHead = this.git(repoRoot, ['rev-parse', 'origin/main']);
|
|
172
|
+
async dashboardInput(repoRoot, summary, config) {
|
|
173
|
+
const forkPoint = await this.git(repoRoot, ['merge-base', 'origin/main', 'HEAD']);
|
|
174
|
+
const featureHead = await this.git(repoRoot, ['rev-parse', 'HEAD']);
|
|
175
|
+
const mainHead = await this.git(repoRoot, ['rev-parse', 'origin/main']);
|
|
174
176
|
const range = `${forkPoint}..${featureHead}`;
|
|
175
|
-
const changedFiles = this.git(repoRoot, ['diff', range, '--name-only'])
|
|
177
|
+
const changedFiles = (await this.git(repoRoot, ['diff', range, '--name-only']))
|
|
176
178
|
.split('\n')
|
|
177
179
|
.filter((f) => f.trim() !== '');
|
|
178
180
|
const gateResults = this.dashboard.computeGateResults(config.gates, changedFiles);
|
|
179
|
-
const disables = this.dashboard.countAddedDisables(this.git(repoRoot, ['diff', range]));
|
|
181
|
+
const disables = this.dashboard.countAddedDisables(await this.git(repoRoot, ['diff', range]));
|
|
180
182
|
const buildCommand = this.buildAffected.resolveBuildCommand(repoRoot);
|
|
181
183
|
const title = this.titleFrom(summary, this.branchIdentity.current());
|
|
182
184
|
return new dashboard_1.DashboardInput(title, gateResults, disables, true, forkPoint, featureHead, mainHead, summary, [], buildCommand, 0, this.authorIdentity.resolve(summary.model), true);
|
|
183
185
|
}
|
|
184
186
|
/** The 1st comment (full dashboard) and, when the repo defines checklists, the bypassed-roster 2nd. */
|
|
185
|
-
postComments(repoRoot, featureName, ref, summary) {
|
|
187
|
+
async postComments(repoRoot, featureName, ref, summary) {
|
|
186
188
|
if (ref.number === '') {
|
|
187
189
|
process.stderr.write(`⚠️ Could not resolve the PR number after the push, so the audit comments were not posted. The PR body\n still carries the hotfix banner. Re-run ${hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND} to post them.\n`);
|
|
188
190
|
return;
|
|
@@ -193,14 +195,14 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
|
|
|
193
195
|
detail.prNumber = ref.number;
|
|
194
196
|
detail.marker = dashboard_1.DETAIL_COMMENT_MARKER;
|
|
195
197
|
// The audit banner must be the FIRST thing on the comment, so the marker goes last.
|
|
196
|
-
detail.body = this.dashboard.renderDetailComment(this.dashboardInput(repoRoot, summary, config)) + '\n\n' + dashboard_1.DETAIL_COMMENT_MARKER;
|
|
198
|
+
detail.body = this.dashboard.renderDetailComment(await this.dashboardInput(repoRoot, summary, config)) + '\n\n' + dashboard_1.DETAIL_COMMENT_MARKER;
|
|
197
199
|
detail.payloadDir = prDir;
|
|
198
200
|
detail.payloadName = 'detail-comment.json';
|
|
199
201
|
detail.label = 'full dashboard comment';
|
|
200
|
-
this.commentUpserter.upsert(detail);
|
|
202
|
+
await this.commentUpserter.upsert(detail);
|
|
201
203
|
if (config.checklists.length === 0 || !config.checklistComments)
|
|
202
204
|
return;
|
|
203
|
-
const scan = this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(config.maxReviewerRounds, false, ''));
|
|
205
|
+
const scan = await this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(config.maxReviewerRounds, false, ''));
|
|
204
206
|
const rows = scan.roster.entries.map((entry) => new checklist_comment_row_1.ChecklistCommentRow('none', 'none', entry.def.id, '', '', entry.matchedFiles.length > 0, entry.def.patterns, entry.matchedPatterns, entry.matchedFiles, scan.roster.changedFileCount));
|
|
205
207
|
const roster = new pr_comment_upserter_1.PrCommentRequest();
|
|
206
208
|
roster.prNumber = ref.number;
|
|
@@ -209,7 +211,7 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
|
|
|
209
211
|
roster.payloadDir = prDir;
|
|
210
212
|
roster.payloadName = 'checklist-comment.json';
|
|
211
213
|
roster.label = 'checklist review comment';
|
|
212
|
-
this.commentUpserter.upsert(roster);
|
|
214
|
+
await this.commentUpserter.upsert(roster);
|
|
213
215
|
}
|
|
214
216
|
closingBlock(ref, title, branch) {
|
|
215
217
|
const link = ref.url === '' ? '(PR URL unresolved — see the gh output above)' : ref.url;
|
|
@@ -239,25 +241,25 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
|
|
|
239
241
|
git(repoRoot, args) {
|
|
240
242
|
return this.gitExec.gitQuery(args, repoRoot, `git ${args.join(' ')} failed in ${repoRoot}`);
|
|
241
243
|
}
|
|
242
|
-
// ──
|
|
244
|
+
// ── seam, protected so the spec drives it with no webpieces.config.json ──
|
|
243
245
|
prGateConfig(repoRoot) {
|
|
244
246
|
return (0, rules_config_1.loadAndValidate)(repoRoot).prGate;
|
|
245
247
|
}
|
|
246
|
-
fetchMain(repoRoot) {
|
|
247
|
-
const out = this.gitExec.tryGit(['fetch', 'origin', 'main'], repoRoot);
|
|
248
|
+
async fetchMain(repoRoot) {
|
|
249
|
+
const out = await this.gitExec.tryGit(['fetch', 'origin', 'main'], repoRoot);
|
|
248
250
|
if (out.ok)
|
|
249
251
|
return;
|
|
250
252
|
throw new rules_config_1.CliExitError(1, `❌ Could not fetch origin/main (needed to READ the fork point — it is never merged). Nothing was pushed.\n git said: ${out.stderr}`);
|
|
251
253
|
}
|
|
252
|
-
prRef(branch) {
|
|
253
|
-
const out =
|
|
254
|
-
if (out.
|
|
254
|
+
async prRef(branch) {
|
|
255
|
+
const out = await this.processes.run('gh', ['pr', 'view', branch, '--json', 'number,url', '--jq', '"\\(.number)\\t\\(.url)"']);
|
|
256
|
+
if (!out.ok)
|
|
255
257
|
return new HotfixPrRef('', '');
|
|
256
|
-
const parts =
|
|
258
|
+
const parts = out.stdout.trim().split('\t');
|
|
257
259
|
return new HotfixPrRef(parts[0] ?? '', parts[1] ?? '');
|
|
258
260
|
}
|
|
259
|
-
editPrBody(prNumber, bodyFile) {
|
|
260
|
-
return (
|
|
261
|
+
async editPrBody(prNumber, bodyFile) {
|
|
262
|
+
return (await this.processes.passThrough('gh', ['pr', 'edit', prNumber, '--body-file', bodyFile])).ok;
|
|
261
263
|
}
|
|
262
264
|
};
|
|
263
265
|
exports.UpsertHotfixPrCommand = UpsertHotfixPrCommand;
|
|
@@ -278,6 +280,7 @@ exports.UpsertHotfixPrCommand = UpsertHotfixPrCommand = tslib_1.__decorate([
|
|
|
278
280
|
checklist_comment_renderer_1.ChecklistCommentRenderer,
|
|
279
281
|
pr_comment_upserter_1.PrCommentUpserter,
|
|
280
282
|
squash_settings_enforcer_1.SquashSettingsEnforcer,
|
|
281
|
-
rules_config_1.GateTokenService
|
|
283
|
+
rules_config_1.GateTokenService,
|
|
284
|
+
tooling_common_1.NativeProcessApi])
|
|
282
285
|
], UpsertHotfixPrCommand);
|
|
283
286
|
//# sourceMappingURL=upsert-hotfix-pr-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert-hotfix-pr-command.js","sourceRoot":"","sources":["../../../../../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AC,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAES,UAAU,CAAC,QAAgB,EAAE,QAAgB;QACnD,OAAO,IAAA,yBAAS,EAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACjH,CAAC;CACJ,CAAA;AA1NY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIA,6BAAc;QACd,mCAAc;QAChB,mCAAY;QACjB,kBAAO;QACG,gCAAiB;QACrB,8BAAa;QACT,uCAAiB;QACxB,wBAAU;QACJ,oCAAgB;QACvB,uCAAiB;QACjB,qBAAS;QACJ,wCAAsB;QACpB,qDAAwB;QACzB,uCAAiB;QAClB,iDAAsB;QACpB,+BAAgB;GAlB9C,qBAAqB,CA0NjC","sourcesContent":["import { spawnSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { BranchIdentity } from '@webpieces/repo-workflow-core';\nimport { CliExitError, GateTokenService, PrGateConfig, PrSummary, RepoRootFinder, ReviewJsonService, loadAndValidate, writeTemplate } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { GitExec } from '../workflow/git-exec';\nimport { BuildAffected, BuildGateOptions } from '../workflow/build-affected';\nimport { BuildArtifactGate } from '../workflow/build-artifact-gate';\nimport { FINISH_STAGE } from '../workflow/build-gate-log';\nimport { MergeState } from '../workflow/merge-state';\nimport { ChecklistScanOptions, ChecklistScanner } from '../workflow/checklist-scanner';\nimport { TriggeredChecklist } from '../workflow/checklist-detector';\nimport { HotfixPrPublisher } from '../workflow/hotfix-pr-publisher';\nimport { UPSERT_HOTFIX_PR_COMMAND } from '../workflow/hotfix-redirect';\nimport { PrCommentRequest, PrCommentUpserter } from '../workflow/pr-comment-upserter';\nimport { SquashSettingsEnforcer } from '../workflow/squash-settings-enforcer';\nimport { Dashboard, DashboardInput, DETAIL_COMMENT_MARKER } from '../../dashboard/dashboard';\nimport { ChecklistCommentRenderer, CHECKLIST_COMMENT_MARKER } from '../../dashboard/checklist-comment-renderer';\nimport { ChecklistCommentRow } from '../../dashboard/checklist-comment-row';\nimport { AuthorIdentityResolver } from '../../dashboard/author-identity';\nimport { IssueReferences } from '../../dashboard/issue-references';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The PR this run landed on. Both '' when it could not be resolved. Data-only, per CLAUDE.md. */\nexport class HotfixPrRef {\n number: string;\n url: string;\n\n constructor(number: string, url: string) {\n this.number = number;\n this.url = url;\n }\n}\n\n/**\n * `wp-upsert-hotfix-pr` — the ONE command that publishes a `/hotfix/` branch (issue #1057).\n *\n * A hotfix branch is cut from the exact sha running in production, so that what ships is production plus\n * the fix and nothing else. The three-stage PR flow cannot publish it: stage ① merges main into the branch,\n * which turns \"prod + fix\" into \"main + fix\" and ships every commit that has landed but has not been\n * promoted. And a hotfix runs no reviewers, so the stages have nothing to do between them. This is the\n * whole flow, in one command, in this order:\n *\n * 1. refuse unless the branch carries the exact, case-sensitive `/hotfix/` segment;\n * 2. require a clean tree and summary.json — a missing one prints its path and schema and exits;\n * 3. run ONLY the `hotfix-ci` gate (build + test). Red means nothing is pushed;\n * 4. NEVER merge main into the branch, never squash it, never rewrite it — HEAD is checked unchanged;\n * 5. push ONCE, fast-forward only, as a child process (pr-creation-or-push-guard stays intact);\n * 6. create or update the audit-bannered PR to main, and NEVER enable auto-merge — the consumer merges\n * after it has deployed and verified the hotfix. Re-running after another commit pushes again and\n * updates the same PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class UpsertHotfixPrCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly branchIdentity: BranchIdentity,\n private readonly aiBranchName: AiBranchName,\n private readonly gitExec: GitExec,\n private readonly reviewJsonService: ReviewJsonService,\n private readonly buildAffected: BuildAffected,\n private readonly buildArtifactGate: BuildArtifactGate,\n private readonly mergeState: MergeState,\n private readonly checklistScanner: ChecklistScanner,\n private readonly publisher: HotfixPrPublisher,\n private readonly dashboard: Dashboard,\n private readonly authorIdentity: AuthorIdentityResolver,\n private readonly checklistComment: ChecklistCommentRenderer,\n private readonly commentUpserter: PrCommentUpserter,\n private readonly squashSettings: SquashSettingsEnforcer,\n private readonly gateTokenService: GateTokenService,\n ) {}\n\n async run(): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n const branch = this.branchIdentity.current();\n // FIRST, before any write: a non-hotfix branch gets nothing from this command, not even a template.\n this.assertHotfixBranch(branch);\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n this.gitExec.assertCleanTree(repoRoot);\n this.assertNoUnvalidatedMerge(repoRoot);\n\n const featureName = this.aiBranchName.getFeatureName();\n const summaryPath = this.reviewJsonService.summaryJsonPath(repoRoot, featureName);\n // Throws InformAiError carrying the path and the schema when summary.json is missing or invalid.\n const summary = this.reviewJsonService.loadSummaryJson(summaryPath, [], '', {}, UPSERT_HOTFIX_PR_COMMAND);\n // FAIL FAST on a hand-written closing reference (issue #1310); renderPrBody re-judges the final body.\n new IssueReferences().assertNoStrayClosingReferences(summary.summary, summary.addressesIssues, UPSERT_HOTFIX_PR_COMMAND);\n\n // origin/main is READ (the build's merge-base and the dashboard's fork point) — never merged.\n this.fetchMain(repoRoot);\n const headBefore = this.headSha(repoRoot);\n await this.buildAffected.runBuildGate(\n repoRoot,\n new BuildGateOptions('🛠️ Hotfix build gate (hotfix-ci: build + test only)', UPSERT_HOTFIX_PR_COMMAND, 'Hotfix build failed — nothing was pushed and no PR was created or updated.', FINISH_STAGE),\n );\n this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);\n this.gitExec.assertCleanTree(repoRoot);\n if (this.headSha(repoRoot) !== headBefore) {\n throw new CliExitError(1, `❌ HEAD moved while the hotfix build ran, so the build does not cover the commit that would be pushed. Nothing was pushed. Re-run ${UPSERT_HOTFIX_PR_COMMAND}.`);\n }\n\n const ref = this.publish(repoRoot, branch, summary, headBefore);\n this.postComments(repoRoot, featureName, ref, summary);\n this.squashSettings.ensure();\n const archived = this.reviewJsonService.archiveSummaryJson(summaryPath);\n if (archived !== '') process.stdout.write(` archived this run's summary.json → ${archived} (audit only) ✓\\n`);\n process.stdout.write(this.closingBlock(ref, summary.title, branch));\n }\n\n private assertHotfixBranch(branch: string): void {\n if (this.branchIdentity.isHotfix(branch)) return;\n throw new CliExitError(\n 1,\n `wp-upsert-hotfix-pr only runs on a branch containing the exact, case-sensitive /hotfix/ segment; '${branch}' does not.\\n` +\n 'Nothing was changed. A normal branch is published with the three-stage flow:\\n' +\n ' pnpm wp-start-upsert-pr\\n pnpm wp-review-upsert-pr\\n pnpm wp-finish-upsert-pr',\n );\n }\n\n // A hotfix flow never STARTS a merge, but a branch somebody ran wp-start-update on can carry one.\n private assertNoUnvalidatedMerge(repoRoot: string): void {\n const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());\n const active = this.mergeState.findActiveMergeRunDir(home);\n const marker = active === null ? null : this.mergeState.readMergeMarker(active);\n if (marker === null || marker.validated) return;\n throw new CliExitError(\n 1,\n 'wp-upsert-hotfix-pr refuses a branch with an active, unvalidated 3-point merge. A hotfix branch must\\n' +\n 'not take main at all: abort that merge and return the branch to the production sha plus your fix\\n' +\n `commits, then re-run ${UPSERT_HOTFIX_PR_COMMAND}. Nothing was pushed.`,\n );\n }\n\n /** Body before push (GatedPrPublisher's ordering), fast-forward push, then create or edit — never merge. */\n private publish(repoRoot: string, branch: string, summary: PrSummary, headSha: string): HotfixPrRef {\n const config = this.prGateConfig(repoRoot);\n const input = this.dashboardInput(repoRoot, summary, config);\n const tokenSuffix = this.tokenSuffix(config.gateSalt, headSha);\n const initial = this.prRef(branch);\n const body = this.dashboard.renderPrBody(input, initial.url) + tokenSuffix;\n for (const warning of new IssueReferences().closeWarnings(summary.addressesIssues)) process.stdout.write(`${warning}\\n`);\n const bodyFile = path.join(this.reviewJsonService.prDirFor(repoRoot, this.aiBranchName.getFeatureName()), 'pr-body.md');\n fs.mkdirSync(path.dirname(bodyFile), { recursive: true });\n fs.writeFileSync(bodyFile, body + '\\n');\n\n process.stdout.write('\\n' + SEP + '📋 Hotfix PR (bannered audit, never auto-merged)\\n' + SEP + '\\n');\n const published = this.publisher.publish(branch, this.titleFrom(summary, branch), bodyFile, UPSERT_HOTFIX_PR_COMMAND);\n if (published.createFailed) {\n throw new CliExitError(1, `❌ gh pr create failed after the push. The rendered body is in ${bodyFile}; summary.json was kept. Re-run ${UPSERT_HOTFIX_PR_COMMAND}.`);\n }\n const ref = this.prRef(branch);\n const resolved = new HotfixPrRef(ref.number !== '' ? ref.number : published.number, ref.url);\n // A brand-new PR had no URL to self-link until `gh pr create` returned one.\n const finalBody = this.dashboard.renderPrBody(input, resolved.url) + tokenSuffix;\n if (finalBody !== body && resolved.number !== '') {\n fs.writeFileSync(bodyFile, finalBody + '\\n');\n if (!this.editPrBody(resolved.number, bodyFile)) {\n process.stderr.write(`⚠️ Could not add the PR's own link to its description (non-fatal — the PR and the gate token are up).\\n`);\n }\n }\n return resolved;\n }\n\n private dashboardInput(repoRoot: string, summary: PrSummary, config: PrGateConfig): DashboardInput {\n const forkPoint = this.git(repoRoot, ['merge-base', 'origin/main', 'HEAD']);\n const featureHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n const mainHead = this.git(repoRoot, ['rev-parse', 'origin/main']);\n const range = `${forkPoint}..${featureHead}`;\n const changedFiles = this.git(repoRoot, ['diff', range, '--name-only'])\n .split('\\n')\n .filter((f: string): boolean => f.trim() !== '');\n const gateResults = this.dashboard.computeGateResults(config.gates, changedFiles);\n const disables = this.dashboard.countAddedDisables(this.git(repoRoot, ['diff', range]));\n const buildCommand = this.buildAffected.resolveBuildCommand(repoRoot);\n const title = this.titleFrom(summary, this.branchIdentity.current());\n return new DashboardInput(title, gateResults, disables, true, forkPoint, featureHead, mainHead, summary, [], buildCommand, 0, this.authorIdentity.resolve(summary.model), true);\n }\n\n /** The 1st comment (full dashboard) and, when the repo defines checklists, the bypassed-roster 2nd. */\n private postComments(repoRoot: string, featureName: string, ref: HotfixPrRef, summary: PrSummary): void {\n if (ref.number === '') {\n process.stderr.write(`⚠️ Could not resolve the PR number after the push, so the audit comments were not posted. The PR body\\n still carries the hotfix banner. Re-run ${UPSERT_HOTFIX_PR_COMMAND} to post them.\\n`);\n return;\n }\n const config = this.prGateConfig(repoRoot);\n const prDir = this.reviewJsonService.prDirFor(repoRoot, featureName);\n const detail = new PrCommentRequest();\n detail.prNumber = ref.number;\n detail.marker = DETAIL_COMMENT_MARKER;\n // The audit banner must be the FIRST thing on the comment, so the marker goes last.\n detail.body = this.dashboard.renderDetailComment(this.dashboardInput(repoRoot, summary, config)) + '\\n\\n' + DETAIL_COMMENT_MARKER;\n detail.payloadDir = prDir;\n detail.payloadName = 'detail-comment.json';\n detail.label = 'full dashboard comment';\n this.commentUpserter.upsert(detail);\n\n if (config.checklists.length === 0 || !config.checklistComments) return;\n const scan = this.checklistScanner.scan(repoRoot, config.checklists, new ChecklistScanOptions(config.maxReviewerRounds, false, ''));\n const rows = scan.roster.entries.map(\n (entry: TriggeredChecklist): ChecklistCommentRow =>\n new ChecklistCommentRow('none', 'none', entry.def.id, '', '', entry.matchedFiles.length > 0, entry.def.patterns, entry.matchedPatterns, entry.matchedFiles, scan.roster.changedFileCount),\n );\n const roster = new PrCommentRequest();\n roster.prNumber = ref.number;\n roster.marker = CHECKLIST_COMMENT_MARKER;\n roster.body = this.checklistComment.render(rows, false, scan.roster.baseResolved, 0, true);\n roster.payloadDir = prDir;\n roster.payloadName = 'checklist-comment.json';\n roster.label = 'checklist review comment';\n this.commentUpserter.upsert(roster);\n }\n\n private closingBlock(ref: HotfixPrRef, title: string, branch: string): string {\n const link = ref.url === '' ? '(PR URL unresolved — see the gh output above)' : ref.url;\n return (\n '\\n' +\n SEP +\n `✅ Hotfix PR ${ref.number === '' ? '' : `#${ref.number} `}is up — NOT merged, and auto-merge was NOT enabled\\n` +\n SEP +\n '\\n' +\n ' 1. ran hotfix-ci (build + test only); lint, validators and reviewers are bypassed and bannered\\n' +\n ` 2. pushed ${branch} fast-forward only — main was never merged in and the branch was not rewritten\\n` +\n ` 3. wrote the audit-bannered body to the PR titled: \"${title}\"\\n\\n` +\n ' A hotfix PR is never auto-merged. Deploy and verify the hotfix first; the merge to main is then a\\n' +\n ' deliberate step (pnpm wp-land-pr). Another commit on this branch? Commit it and re-run\\n' +\n ` ${UPSERT_HOTFIX_PR_COMMAND} — it pushes again and updates this same PR.\\n\\n` +\n `🔗 ${link}\\n`\n );\n }\n\n private tokenSuffix(gateSalt: string, headSha: string): string {\n const marker = this.gateTokenService.gateTokenMarker(gateSalt, headSha);\n return marker === '' ? '' : `\\n\\n${marker}\\n`;\n }\n\n private titleFrom(summary: PrSummary, branch: string): string {\n return summary.title !== '' ? summary.title : branch.replace(/[-/]+/g, ' ').trim();\n }\n\n private headSha(repoRoot: string): string {\n return this.git(repoRoot, ['rev-parse', 'HEAD']);\n }\n\n private git(repoRoot: string, args: string[]): string {\n return this.gitExec.gitQuery(args, repoRoot, `git ${args.join(' ')} failed in ${repoRoot}`);\n }\n\n // ── seams, protected so the spec drives them with no network, no gh and no webpieces.config.json ──\n\n protected prGateConfig(repoRoot: string): PrGateConfig {\n return loadAndValidate(repoRoot).prGate;\n }\n\n protected fetchMain(repoRoot: string): void {\n const out = this.gitExec.tryGit(['fetch', 'origin', 'main'], repoRoot);\n if (out.ok) return;\n throw new CliExitError(1, `❌ Could not fetch origin/main (needed to READ the fork point — it is never merged). Nothing was pushed.\\n git said: ${out.stderr}`);\n }\n\n protected prRef(branch: string): HotfixPrRef {\n const out = spawnSync('gh', ['pr', 'view', branch, '--json', 'number,url', '--jq', '\"\\\\(.number)\\\\t\\\\(.url)\"'], { encoding: 'utf8' });\n if (out.status !== 0) return new HotfixPrRef('', '');\n const parts = (out.stdout ?? '').trim().split('\\t');\n return new HotfixPrRef(parts[0] ?? '', parts[1] ?? '');\n }\n\n protected editPrBody(prNumber: string, bodyFile: string): boolean {\n return spawnSync('gh', ['pr', 'edit', prNumber, '--body-file', bodyFile], { stdio: 'inherit' }).status === 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"upsert-hotfix-pr-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/upsert-hotfix-pr-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,sEAA+D;AAC/D,0DAAqK;AACrK,8DAA6D;AAC7D,yCAA2D;AAC3D,2EAAgE;AAChE,mDAA+C;AAC/C,+DAA6E;AAC7E,yEAAoE;AACpE,+DAA0D;AAC1D,yDAAqD;AACrD,qEAAuF;AAEvF,yEAAoE;AACpE,iEAAuE;AACvE,yEAAsF;AACtF,mFAA8E;AAC9E,yDAA6F;AAC7F,2FAAgH;AAChH,iFAA4E;AAC5E,qEAAyE;AACzE,uEAAmE;AAEnE,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,kGAAkG;AAClG,MAAa,WAAW;IACpB,MAAM,CAAS;IACf,GAAG,CAAS;IAEZ,YAAY,MAAc,EAAE,GAAW;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AARD,kCAQC;AAED;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAGT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAlB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,oCAAgB;QACvB,uCAAiB;QACjB,qBAAS;QACJ,wCAAsB;QACpB,qDAAwB;QACzB,uCAAiB;QAClB,iDAAsB;QACpB,+BAAgB;QACvB,iCAAgB;GAnBvC,qBAAqB,CA2NjC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { BranchIdentity } from '@webpieces/repo-workflow-core';\nimport { CliExitError, GateTokenService, PrGateConfig, PrSummary, RepoRootFinder, ReviewJsonService, loadAndValidate, writeTemplate } from '@webpieces/rules-config';\nimport { NativeProcessApi } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { GitExec } from '../workflow/git-exec';\nimport { BuildAffected, BuildGateOptions } from '../workflow/build-affected';\nimport { BuildArtifactGate } from '../workflow/build-artifact-gate';\nimport { FINISH_STAGE } from '../workflow/build-gate-log';\nimport { MergeState } from '../workflow/merge-state';\nimport { ChecklistScanOptions, ChecklistScanner } from '../workflow/checklist-scanner';\nimport { TriggeredChecklist } from '../workflow/checklist-detector';\nimport { HotfixPrPublisher } from '../workflow/hotfix-pr-publisher';\nimport { UPSERT_HOTFIX_PR_COMMAND } from '../workflow/hotfix-redirect';\nimport { PrCommentRequest, PrCommentUpserter } from '../workflow/pr-comment-upserter';\nimport { SquashSettingsEnforcer } from '../workflow/squash-settings-enforcer';\nimport { Dashboard, DashboardInput, DETAIL_COMMENT_MARKER } from '../../dashboard/dashboard';\nimport { ChecklistCommentRenderer, CHECKLIST_COMMENT_MARKER } from '../../dashboard/checklist-comment-renderer';\nimport { ChecklistCommentRow } from '../../dashboard/checklist-comment-row';\nimport { AuthorIdentityResolver } from '../../dashboard/author-identity';\nimport { IssueReferences } from '../../dashboard/issue-references';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The PR this run landed on. Both '' when it could not be resolved. Data-only, per CLAUDE.md. */\nexport class HotfixPrRef {\n number: string;\n url: string;\n\n constructor(number: string, url: string) {\n this.number = number;\n this.url = url;\n }\n}\n\n/**\n * `wp-upsert-hotfix-pr` — the ONE command that publishes a `/hotfix/` branch (issue #1057).\n *\n * A hotfix branch is cut from the exact sha running in production, so that what ships is production plus\n * the fix and nothing else. The three-stage PR flow cannot publish it: stage ① merges main into the branch,\n * which turns \"prod + fix\" into \"main + fix\" and ships every commit that has landed but has not been\n * promoted. And a hotfix runs no reviewers, so the stages have nothing to do between them. This is the\n * whole flow, in one command, in this order:\n *\n * 1. refuse unless the branch carries the exact, case-sensitive `/hotfix/` segment;\n * 2. require a clean tree and summary.json — a missing one prints its path and schema and exits;\n * 3. run ONLY the `hotfix-ci` gate (build + test). Red means nothing is pushed;\n * 4. NEVER merge main into the branch, never squash it, never rewrite it — HEAD is checked unchanged;\n * 5. push ONCE, fast-forward only, as a child process (pr-creation-or-push-guard stays intact);\n * 6. create or update the audit-bannered PR to main, and NEVER enable auto-merge — the consumer merges\n * after it has deployed and verified the hotfix. Re-running after another commit pushes again and\n * updates the same PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class UpsertHotfixPrCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly branchIdentity: BranchIdentity,\n private readonly aiBranchName: AiBranchName,\n private readonly gitExec: GitExec,\n private readonly reviewJsonService: ReviewJsonService,\n private readonly buildAffected: BuildAffected,\n private readonly buildArtifactGate: BuildArtifactGate,\n private readonly mergeState: MergeState,\n private readonly checklistScanner: ChecklistScanner,\n private readonly publisher: HotfixPrPublisher,\n private readonly dashboard: Dashboard,\n private readonly authorIdentity: AuthorIdentityResolver,\n private readonly checklistComment: ChecklistCommentRenderer,\n private readonly commentUpserter: PrCommentUpserter,\n private readonly squashSettings: SquashSettingsEnforcer,\n private readonly gateTokenService: GateTokenService,\n private readonly processes: NativeProcessApi,\n ) {}\n\n async run(): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n const branch = this.branchIdentity.current();\n // FIRST, before any write: a non-hotfix branch gets nothing from this command, not even a template.\n this.assertHotfixBranch(branch);\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n await this.gitExec.assertCleanTree(repoRoot);\n await this.assertNoUnvalidatedMerge(repoRoot);\n\n const featureName = await this.aiBranchName.getFeatureName();\n const summaryPath = this.reviewJsonService.summaryJsonPath(repoRoot, featureName);\n // Throws InformAiError carrying the path and the schema when summary.json is missing or invalid.\n const summary = this.reviewJsonService.loadSummaryJson(summaryPath, [], '', {}, UPSERT_HOTFIX_PR_COMMAND);\n // FAIL FAST on a hand-written closing reference (issue #1310); renderPrBody re-judges the final body.\n new IssueReferences().assertNoStrayClosingReferences(summary.summary, summary.addressesIssues, UPSERT_HOTFIX_PR_COMMAND);\n\n // origin/main is READ (the build's merge-base and the dashboard's fork point) — never merged.\n await this.fetchMain(repoRoot);\n const headBefore = await this.headSha(repoRoot);\n await this.buildAffected.runBuildGate(\n repoRoot,\n new BuildGateOptions('🛠️ Hotfix build gate (hotfix-ci: build + test only)', UPSERT_HOTFIX_PR_COMMAND, 'Hotfix build failed — nothing was pushed and no PR was created or updated.', FINISH_STAGE),\n );\n await this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);\n await this.gitExec.assertCleanTree(repoRoot);\n if (await this.headSha(repoRoot) !== headBefore) {\n throw new CliExitError(1, `❌ HEAD moved while the hotfix build ran, so the build does not cover the commit that would be pushed. Nothing was pushed. Re-run ${UPSERT_HOTFIX_PR_COMMAND}.`);\n }\n\n const ref = await this.publish(repoRoot, branch, summary, headBefore);\n await this.postComments(repoRoot, featureName, ref, summary);\n await this.squashSettings.ensure();\n const archived = this.reviewJsonService.archiveSummaryJson(summaryPath);\n if (archived !== '') process.stdout.write(` archived this run's summary.json → ${archived} (audit only) ✓\\n`);\n process.stdout.write(this.closingBlock(ref, summary.title, branch));\n }\n\n private assertHotfixBranch(branch: string): void {\n if (this.branchIdentity.isHotfix(branch)) return;\n throw new CliExitError(\n 1,\n `wp-upsert-hotfix-pr only runs on a branch containing the exact, case-sensitive /hotfix/ segment; '${branch}' does not.\\n` +\n 'Nothing was changed. A normal branch is published with the three-stage flow:\\n' +\n ' pnpm wp-start-upsert-pr\\n pnpm wp-review-upsert-pr\\n pnpm wp-finish-upsert-pr',\n );\n }\n\n // A hotfix flow never STARTS a merge, but a branch somebody ran wp-start-update on can carry one.\n private async assertNoUnvalidatedMerge(repoRoot: string): Promise<void> {\n const home = this.mergeState.mergeDirFor(repoRoot, await this.aiBranchName.getFeatureName());\n const active = this.mergeState.findActiveMergeRunDir(home);\n const marker = active === null ? null : this.mergeState.readMergeMarker(active);\n if (marker === null || marker.validated) return;\n throw new CliExitError(\n 1,\n 'wp-upsert-hotfix-pr refuses a branch with an active, unvalidated 3-point merge. A hotfix branch must\\n' +\n 'not take main at all: abort that merge and return the branch to the production sha plus your fix\\n' +\n `commits, then re-run ${UPSERT_HOTFIX_PR_COMMAND}. Nothing was pushed.`,\n );\n }\n\n /** Body before push (GatedPrPublisher's ordering), fast-forward push, then create or edit — never merge. */\n private async publish(repoRoot: string, branch: string, summary: PrSummary, headSha: string): Promise<HotfixPrRef> {\n const config = this.prGateConfig(repoRoot);\n const input = await this.dashboardInput(repoRoot, summary, config);\n const tokenSuffix = this.tokenSuffix(config.gateSalt, headSha);\n const initial = await this.prRef(branch);\n const body = this.dashboard.renderPrBody(input, initial.url) + tokenSuffix;\n for (const warning of new IssueReferences().closeWarnings(summary.addressesIssues)) process.stdout.write(`${warning}\\n`);\n const bodyFile = path.join(this.reviewJsonService.prDirFor(repoRoot, await this.aiBranchName.getFeatureName()), 'pr-body.md');\n fs.mkdirSync(path.dirname(bodyFile), { recursive: true });\n fs.writeFileSync(bodyFile, body + '\\n');\n\n process.stdout.write('\\n' + SEP + '📋 Hotfix PR (bannered audit, never auto-merged)\\n' + SEP + '\\n');\n const published = await this.publisher.publish(branch, this.titleFrom(summary, branch), bodyFile, UPSERT_HOTFIX_PR_COMMAND);\n if (published.createFailed) {\n throw new CliExitError(1, `❌ gh pr create failed after the push. The rendered body is in ${bodyFile}; summary.json was kept. Re-run ${UPSERT_HOTFIX_PR_COMMAND}.`);\n }\n const ref = await this.prRef(branch);\n const resolved = new HotfixPrRef(ref.number !== '' ? ref.number : published.number, ref.url);\n // A brand-new PR had no URL to self-link until `gh pr create` returned one.\n const finalBody = this.dashboard.renderPrBody(input, resolved.url) + tokenSuffix;\n if (finalBody !== body && resolved.number !== '') {\n fs.writeFileSync(bodyFile, finalBody + '\\n');\n if (!(await this.editPrBody(resolved.number, bodyFile))) {\n process.stderr.write(`⚠️ Could not add the PR's own link to its description (non-fatal — the PR and the gate token are up).\\n`);\n }\n }\n return resolved;\n }\n\n private async dashboardInput(repoRoot: string, summary: PrSummary, config: PrGateConfig): Promise<DashboardInput> {\n const forkPoint = await this.git(repoRoot, ['merge-base', 'origin/main', 'HEAD']);\n const featureHead = await this.git(repoRoot, ['rev-parse', 'HEAD']);\n const mainHead = await this.git(repoRoot, ['rev-parse', 'origin/main']);\n const range = `${forkPoint}..${featureHead}`;\n const changedFiles = (await this.git(repoRoot, ['diff', range, '--name-only']))\n .split('\\n')\n .filter((f: string): boolean => f.trim() !== '');\n const gateResults = this.dashboard.computeGateResults(config.gates, changedFiles);\n const disables = this.dashboard.countAddedDisables(await this.git(repoRoot, ['diff', range]));\n const buildCommand = this.buildAffected.resolveBuildCommand(repoRoot);\n const title = this.titleFrom(summary, this.branchIdentity.current());\n return new DashboardInput(title, gateResults, disables, true, forkPoint, featureHead, mainHead, summary, [], buildCommand, 0, this.authorIdentity.resolve(summary.model), true);\n }\n\n /** The 1st comment (full dashboard) and, when the repo defines checklists, the bypassed-roster 2nd. */\n private async postComments(repoRoot: string, featureName: string, ref: HotfixPrRef, summary: PrSummary): Promise<void> {\n if (ref.number === '') {\n process.stderr.write(`⚠️ Could not resolve the PR number after the push, so the audit comments were not posted. The PR body\\n still carries the hotfix banner. Re-run ${UPSERT_HOTFIX_PR_COMMAND} to post them.\\n`);\n return;\n }\n const config = this.prGateConfig(repoRoot);\n const prDir = this.reviewJsonService.prDirFor(repoRoot, featureName);\n const detail = new PrCommentRequest();\n detail.prNumber = ref.number;\n detail.marker = DETAIL_COMMENT_MARKER;\n // The audit banner must be the FIRST thing on the comment, so the marker goes last.\n detail.body = this.dashboard.renderDetailComment(await this.dashboardInput(repoRoot, summary, config)) + '\\n\\n' + DETAIL_COMMENT_MARKER;\n detail.payloadDir = prDir;\n detail.payloadName = 'detail-comment.json';\n detail.label = 'full dashboard comment';\n await this.commentUpserter.upsert(detail);\n\n if (config.checklists.length === 0 || !config.checklistComments) return;\n const scan = await this.checklistScanner.scan(repoRoot, config.checklists, new ChecklistScanOptions(config.maxReviewerRounds, false, ''));\n const rows = scan.roster.entries.map(\n (entry: TriggeredChecklist): ChecklistCommentRow =>\n new ChecklistCommentRow('none', 'none', entry.def.id, '', '', entry.matchedFiles.length > 0, entry.def.patterns, entry.matchedPatterns, entry.matchedFiles, scan.roster.changedFileCount),\n );\n const roster = new PrCommentRequest();\n roster.prNumber = ref.number;\n roster.marker = CHECKLIST_COMMENT_MARKER;\n roster.body = this.checklistComment.render(rows, false, scan.roster.baseResolved, 0, true);\n roster.payloadDir = prDir;\n roster.payloadName = 'checklist-comment.json';\n roster.label = 'checklist review comment';\n await this.commentUpserter.upsert(roster);\n }\n\n private closingBlock(ref: HotfixPrRef, title: string, branch: string): string {\n const link = ref.url === '' ? '(PR URL unresolved — see the gh output above)' : ref.url;\n return (\n '\\n' +\n SEP +\n `✅ Hotfix PR ${ref.number === '' ? '' : `#${ref.number} `}is up — NOT merged, and auto-merge was NOT enabled\\n` +\n SEP +\n '\\n' +\n ' 1. ran hotfix-ci (build + test only); lint, validators and reviewers are bypassed and bannered\\n' +\n ` 2. pushed ${branch} fast-forward only — main was never merged in and the branch was not rewritten\\n` +\n ` 3. wrote the audit-bannered body to the PR titled: \"${title}\"\\n\\n` +\n ' A hotfix PR is never auto-merged. Deploy and verify the hotfix first; the merge to main is then a\\n' +\n ' deliberate step (pnpm wp-land-pr). Another commit on this branch? Commit it and re-run\\n' +\n ` ${UPSERT_HOTFIX_PR_COMMAND} — it pushes again and updates this same PR.\\n\\n` +\n `🔗 ${link}\\n`\n );\n }\n\n private tokenSuffix(gateSalt: string, headSha: string): string {\n const marker = this.gateTokenService.gateTokenMarker(gateSalt, headSha);\n return marker === '' ? '' : `\\n\\n${marker}\\n`;\n }\n\n private titleFrom(summary: PrSummary, branch: string): string {\n return summary.title !== '' ? summary.title : branch.replace(/[-/]+/g, ' ').trim();\n }\n\n private headSha(repoRoot: string): Promise<string> {\n return this.git(repoRoot, ['rev-parse', 'HEAD']);\n }\n\n private git(repoRoot: string, args: string[]): Promise<string> {\n return this.gitExec.gitQuery(args, repoRoot, `git ${args.join(' ')} failed in ${repoRoot}`);\n }\n\n // ── seam, protected so the spec drives it with no webpieces.config.json ──\n\n protected prGateConfig(repoRoot: string): PrGateConfig {\n return loadAndValidate(repoRoot).prGate;\n }\n\n private async fetchMain(repoRoot: string): Promise<void> {\n const out = await this.gitExec.tryGit(['fetch', 'origin', 'main'], repoRoot);\n if (out.ok) return;\n throw new CliExitError(1, `❌ Could not fetch origin/main (needed to READ the fork point — it is never merged). Nothing was pushed.\\n git said: ${out.stderr}`);\n }\n\n private async prRef(branch: string): Promise<HotfixPrRef> {\n const out = await this.processes.run('gh', ['pr', 'view', branch, '--json', 'number,url', '--jq', '\"\\\\(.number)\\\\t\\\\(.url)\"']);\n if (!out.ok) return new HotfixPrRef('', '');\n const parts = out.stdout.trim().split('\\t');\n return new HotfixPrRef(parts[0] ?? '', parts[1] ?? '');\n }\n\n private async editPrBody(prNumber: string, bodyFile: string): Promise<boolean> {\n return (await this.processes.passThrough('gh', ['pr', 'edit', prNumber, '--body-file', bodyFile])).ok;\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GitProcessApi } from '@webpieces/tooling-common';
|
|
1
2
|
/**
|
|
2
3
|
* The untracked files a branch switch is about to leave exactly where they are — carried out of the gate
|
|
3
4
|
* so the caller can SAY so, rather than surprise anyone with files that appear to have followed them.
|
|
@@ -43,11 +44,13 @@ export declare class UntrackedFiles {
|
|
|
43
44
|
* mangled name for exactly the paths a human most needs to read correctly.
|
|
44
45
|
*/
|
|
45
46
|
export declare class WorkingTreeGate {
|
|
47
|
+
private readonly gitProcess;
|
|
48
|
+
constructor(gitProcess: GitProcessApi);
|
|
46
49
|
/**
|
|
47
50
|
* Throw when tracked files are modified or staged; otherwise hand back the untracked files that were
|
|
48
51
|
* deliberately allowed through, for the caller to mention.
|
|
49
52
|
*/
|
|
50
|
-
assertNoTrackedChanges(repoRoot: string): UntrackedFiles
|
|
53
|
+
assertNoTrackedChanges(repoRoot: string): Promise<UntrackedFiles>;
|
|
51
54
|
private untrackedFiles;
|
|
52
55
|
/** Captured git output, or null when git could not be run or exited non-zero. */
|
|
53
56
|
private git;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkingTreeGate = exports.UntrackedFiles = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
5
|
const inversify_1 = require("inversify");
|
|
7
6
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
7
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
8
8
|
const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
|
|
9
9
|
/**
|
|
10
10
|
* The untracked files a branch switch is about to leave exactly where they are — carried out of the gate
|
|
@@ -63,12 +63,16 @@ exports.UntrackedFiles = UntrackedFiles;
|
|
|
63
63
|
* mangled name for exactly the paths a human most needs to read correctly.
|
|
64
64
|
*/
|
|
65
65
|
let WorkingTreeGate = class WorkingTreeGate {
|
|
66
|
+
gitProcess;
|
|
67
|
+
constructor(gitProcess) {
|
|
68
|
+
this.gitProcess = gitProcess;
|
|
69
|
+
}
|
|
66
70
|
/**
|
|
67
71
|
* Throw when tracked files are modified or staged; otherwise hand back the untracked files that were
|
|
68
72
|
* deliberately allowed through, for the caller to mention.
|
|
69
73
|
*/
|
|
70
|
-
assertNoTrackedChanges(repoRoot) {
|
|
71
|
-
const tracked = this.git(repoRoot, ['status', '--porcelain', '--untracked-files=no']);
|
|
74
|
+
async assertNoTrackedChanges(repoRoot) {
|
|
75
|
+
const tracked = await this.git(repoRoot, ['status', '--porcelain', '--untracked-files=no']);
|
|
72
76
|
if (tracked !== null && tracked.trim() !== '') {
|
|
73
77
|
throw new rules_config_1.CliExitError(1, `${SEP}❌ Uncommitted changes to tracked files\n${SEP}\n`
|
|
74
78
|
+ 'Going to main would carry them along. Commit them on this branch, or `git stash` them\n'
|
|
@@ -78,24 +82,23 @@ let WorkingTreeGate = class WorkingTreeGate {
|
|
|
78
82
|
}
|
|
79
83
|
return this.untrackedFiles(repoRoot);
|
|
80
84
|
}
|
|
81
|
-
untrackedFiles(repoRoot) {
|
|
82
|
-
const output = this.git(repoRoot, ['ls-files', '--others', '--exclude-standard', '-z']);
|
|
85
|
+
async untrackedFiles(repoRoot) {
|
|
86
|
+
const output = await this.git(repoRoot, ['ls-files', '--others', '--exclude-standard', '-z']);
|
|
83
87
|
if (output === null)
|
|
84
88
|
return new UntrackedFiles([]);
|
|
85
89
|
return new UntrackedFiles(output.split('\0').filter((path) => path !== ''));
|
|
86
90
|
}
|
|
87
91
|
/** Captured git output, or null when git could not be run or exited non-zero. */
|
|
88
|
-
git(repoRoot, args) {
|
|
89
|
-
const result =
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
if (result.error !== undefined || result.status !== 0)
|
|
92
|
+
async git(repoRoot, args) {
|
|
93
|
+
const result = await this.gitProcess.run(['-C', repoRoot, ...args]);
|
|
94
|
+
if (!result.ok)
|
|
93
95
|
return null;
|
|
94
96
|
return result.stdout;
|
|
95
97
|
}
|
|
96
98
|
};
|
|
97
99
|
exports.WorkingTreeGate = WorkingTreeGate;
|
|
98
100
|
exports.WorkingTreeGate = WorkingTreeGate = tslib_1.__decorate([
|
|
99
|
-
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton)
|
|
101
|
+
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
102
|
+
tslib_1.__metadata("design:paramtypes", [tooling_common_1.GitProcessApi])
|
|
100
103
|
], WorkingTreeGate);
|
|
101
104
|
//# sourceMappingURL=working-tree-gate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"working-tree-gate.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/working-tree-gate.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"working-tree-gate.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/working-tree-gate.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AAC3D,0DAAuD;AACvD,8DAA0D;AAE1D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;GAGG;AACH,MAAa,cAAc;IACF;IAArB,YAAqB,KAAwB;QAAxB,UAAK,GAAL,KAAK,CAAmB;IAAG,CAAC;IAEjD,OAAO;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,kEAAkE;IAClE,MAAM;QACF,IAAI,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAY,EAAU,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9E,OAAO,0FAA0F;cAC3F,0CAA0C;cAC1C,IAAI,CAAC;IACf,CAAC;CACJ;AAfD,wCAeC;AAED;;;;;;;;;;;;;;;;;;;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,CAAC;QACpE,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QAC5B,OAAO,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC;CACJ,CAAA;AAhCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEI,8BAAa;GAD7C,eAAe,CAgC3B","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\nimport { CliExitError } from '@webpieces/rules-config';\nimport { GitProcessApi } from '@webpieces/tooling-common';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The untracked files a branch switch is about to leave exactly where they are — carried out of the gate\n * so the caller can SAY so, rather than surprise anyone with files that appear to have followed them.\n */\nexport class UntrackedFiles {\n constructor(readonly paths: readonly string[]) {}\n\n isEmpty(): boolean {\n return this.paths.length === 0;\n }\n\n /** The human-facing block, or '' when there is nothing to say. */\n render(): string {\n if (this.isEmpty()) return '';\n const list = this.paths.map((path: string): string => ` ${path}\\n`).join('');\n return 'These untracked files are not on any branch, so the checkout leaves them exactly where\\n'\n + 'they are — nothing about them changed:\\n'\n + list;\n }\n}\n\n/**\n * The clean-tree gate for `wp-sync-main`: refuse when TRACKED work would ride onto main, and\n * only then.\n *\n * ─── WHY UNTRACKED FILES ARE NOT A REASON TO REFUSE ───────────────────────────────────────────────────\n * The hazard the gate exists for is real but narrow: `git checkout` carries uncommitted changes to\n * TRACKED files across the switch, and main is the one place nobody wants to discover their work. An\n * untracked file has none of that. It is not on any branch, the switch does not move it, and no branch\n * can end up holding it — so refusing on one blocks a routine, safe operation.\n *\n * Worse, it was a refusal the user could not clear without deleting their file. The message prescribed\n * \"commit them on this branch, or stash them\", and a plain `git stash` does NOT take untracked files\n * (that needs `-u`) — so a user who did exactly what the error said got the identical refusal back. That\n * is the shape this repo treats as a defect in its own right: a cure that does not resolve the state it\n * is prescribed for. Reported from the field, where a generated `design.html` sitting untracked made the\n * command permanently unusable in that clone.\n *\n * Now the refusal only ever names tracked changes, so `git stash` — the cure it prints — always resolves\n * it, by construction.\n *\n * That is true about the FILES and not about the CHECKOUT: git itself aborts a switch when an untracked\n * file sits at a path the destination branch TRACKS. Letting untracked files through is what makes that\n * abort reachable, and `MainCheckout` is where it is handled — it reacts to git's own refusal by stashing\n * with `-u`, retrying, and shouting about it. This gate does not predict that case, deliberately: git's\n * rules for it are the authority, and re-deriving them here would drift from the git actually installed.\n *\n * ─── WHY `--untracked-files=no` AND `ls-files -z` RATHER THAN PARSING `??` ─────────────────────────────\n * The decision half asks git the tracked-only question directly, so no line of porcelain output is ever\n * parsed to make it. The reporting half asks `ls-files --others --exclude-standard -z`, which emits bare\n * NUL-separated paths — no `?? ` prefix to strip and, crucially, no quoting: porcelain v1 wraps paths\n * containing special characters in quotes with C-style escapes, so a hand-parser would hand back a\n * mangled name for exactly the paths a human most needs to read correctly.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WorkingTreeGate {\n constructor(private readonly gitProcess: GitProcessApi) {}\n\n /**\n * Throw when tracked files are modified or staged; otherwise hand back the untracked files that were\n * deliberately allowed through, for the caller to mention.\n */\n async assertNoTrackedChanges(repoRoot: string): Promise<UntrackedFiles> {\n const tracked = await this.git(repoRoot, ['status', '--porcelain', '--untracked-files=no']);\n if (tracked !== null && tracked.trim() !== '') {\n throw new CliExitError(1,\n `${SEP}❌ Uncommitted changes to tracked files\\n${SEP}\\n`\n + 'Going to main would carry them along. Commit them on this branch, or `git stash` them\\n'\n + '(everything listed below is tracked, which is exactly what a plain stash takes), then\\n'\n + 're-run. The webpieces tooling never commits your work for you.\\n\\n'\n + `${tracked}`);\n }\n return this.untrackedFiles(repoRoot);\n }\n\n private async untrackedFiles(repoRoot: string): Promise<UntrackedFiles> {\n const output = await this.git(repoRoot, ['ls-files', '--others', '--exclude-standard', '-z']);\n if (output === null) return new UntrackedFiles([]);\n return new UntrackedFiles(output.split('\\0').filter((path: string): boolean => path !== ''));\n }\n\n /** Captured git output, or null when git could not be run or exited non-zero. */\n private async git(repoRoot: string, args: string[]): Promise<string | null> {\n const result = await this.gitProcess.run(['-C', repoRoot, ...args]);\n if (!result.ok) return null;\n return result.stdout;\n }\n}\n"]}
|
|
@@ -79,11 +79,11 @@ let WriteReviewCommand = class WriteReviewCommand {
|
|
|
79
79
|
this.provenance = provenance;
|
|
80
80
|
this.reviewJsonService = reviewJsonService;
|
|
81
81
|
}
|
|
82
|
-
run(opts) {
|
|
82
|
+
async run(opts) {
|
|
83
83
|
const id = opts.checklistId.trim();
|
|
84
84
|
const cwd = opts.cwd;
|
|
85
85
|
const repoRoot = this.repoRootFinder.resolveRepoRoot(cwd);
|
|
86
|
-
const featureName = this.aiBranchName.getFeatureName();
|
|
86
|
+
const featureName = await this.aiBranchName.getFeatureName();
|
|
87
87
|
const receipt = this.briefedReceipt(repoRoot, featureName, id);
|
|
88
88
|
// Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it
|
|
89
89
|
// consumes must not survive to lend itself to a later call.
|
|
@@ -96,16 +96,15 @@ let WriteReviewCommand = class WriteReviewCommand {
|
|
|
96
96
|
process.stdout.write(`✅ ${verdict.status.toUpperCase()} verdict for "${id}" submitted → ${written}\n`
|
|
97
97
|
+ ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `
|
|
98
98
|
+ `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\n`);
|
|
99
|
-
return Promise.resolve();
|
|
100
99
|
}
|
|
101
100
|
/**
|
|
102
101
|
* `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse
|
|
103
102
|
* on the budget, so a reviewer past the budget learns it before it reviews rather than after.
|
|
104
103
|
*/
|
|
105
|
-
check(opts) {
|
|
104
|
+
async check(opts) {
|
|
106
105
|
const id = opts.checklistId.trim();
|
|
107
106
|
const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);
|
|
108
|
-
const featureName = this.aiBranchName.getFeatureName();
|
|
107
|
+
const featureName = await this.aiBranchName.getFeatureName();
|
|
109
108
|
const receipt = this.briefedReceipt(repoRoot, featureName, id);
|
|
110
109
|
this.assertWithinBudget((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, id);
|
|
111
110
|
const final = this.isFinalRound(receipt)
|
|
@@ -113,7 +112,6 @@ let WriteReviewCommand = class WriteReviewCommand {
|
|
|
113
112
|
: '';
|
|
114
113
|
process.stdout.write(`✅ "${id}" may be reviewed: this is review round ${receipt.round} of at most ${receipt.maxReviewerRounds}.${final} `
|
|
115
114
|
+ `Review it, then submit with pnpm ${repo_workflow_core_1.WRITE_REVIEW_BIN} --checklist ${id}.\n`);
|
|
116
|
-
return Promise.resolve();
|
|
117
115
|
}
|
|
118
116
|
/** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */
|
|
119
117
|
isFinalRound(receipt) {
|