@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,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FinishUpsertPrCommand = 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 rules_config_1 = require("@webpieces/rules-config");
|
|
@@ -128,6 +127,8 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
128
127
|
stageConsole;
|
|
129
128
|
hotfixRedirect;
|
|
130
129
|
rounds;
|
|
130
|
+
git;
|
|
131
|
+
processes;
|
|
131
132
|
constructor(repoRootFinder, aiBranchName, branchNaming, gitExec, buildAffected, buildLog, mergeState, prMerger, publisher, dashboard, authorIdentity,
|
|
132
133
|
// The 2nd PR comment. Its own class because it is its own surface — see ChecklistCommentRenderer.
|
|
133
134
|
checklistComment, checklistScanner, verdictGate, reviewJsonService, gateTokenService,
|
|
@@ -144,7 +145,7 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
144
145
|
commentUpserter,
|
|
145
146
|
// Pins the two GitHub repo settings that decide whether a UI merge writes the body we just
|
|
146
147
|
// rendered. Server-side, so no config can express them — see SquashSettingsEnforcer.
|
|
147
|
-
squashSettings, stageConsole, hotfixRedirect, rounds) {
|
|
148
|
+
squashSettings, stageConsole, hotfixRedirect, rounds, git, processes) {
|
|
148
149
|
this.repoRootFinder = repoRootFinder;
|
|
149
150
|
this.aiBranchName = aiBranchName;
|
|
150
151
|
this.branchNaming = branchNaming;
|
|
@@ -170,6 +171,8 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
170
171
|
this.stageConsole = stageConsole;
|
|
171
172
|
this.hotfixRedirect = hotfixRedirect;
|
|
172
173
|
this.rounds = rounds;
|
|
174
|
+
this.git = git;
|
|
175
|
+
this.processes = processes;
|
|
173
176
|
}
|
|
174
177
|
/**
|
|
175
178
|
* Runs with this stage's console CAPTURED to a file (see StageOutputLog). What still reaches the
|
|
@@ -188,9 +191,9 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
188
191
|
(0, rules_config_1.writeTemplate)(repoRoot, 'webpieces.git-workflow.md');
|
|
189
192
|
// 1. REQUIRE stage ② — see assertStageTwoRan. Returns true when its receipt covers THIS commit,
|
|
190
193
|
// which is what lets the build gate below be skipped rather than re-run for a foregone answer.
|
|
191
|
-
const featureName = this.aiBranchName.getFeatureName();
|
|
194
|
+
const featureName = await this.aiBranchName.getFeatureName();
|
|
192
195
|
const config = (0, rules_config_1.loadAndValidate)(repoRoot).prGate;
|
|
193
|
-
const buildAlreadyGreen = this.assertStageTwoRan(repoRoot);
|
|
196
|
+
const buildAlreadyGreen = await this.assertStageTwoRan(repoRoot);
|
|
194
197
|
// 2. REQUIRE the AI-authored summary.json (throws InformAiError with the schema if missing/invalid).
|
|
195
198
|
// Compute the consumer checklists this diff triggered FIRST so an unacknowledged BLOCK throws
|
|
196
199
|
// here — BEFORE any `gh pr create` — matching the guarantee buildCommand already provides.
|
|
@@ -202,7 +205,7 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
202
205
|
// until its file is written.
|
|
203
206
|
// The scan judges ONLY the checklists that were briefed (issue #1053) — never one a later commit newly
|
|
204
207
|
// triggered — and it has already folded every recorded orange fix into its results.
|
|
205
|
-
const scan = this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(config.maxReviewerRounds, true, 'stage3-finish'));
|
|
208
|
+
const scan = await this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(config.maxReviewerRounds, true, 'stage3-finish'));
|
|
206
209
|
const required = scan.applicable;
|
|
207
210
|
// The applicable checklists that are supposed to HAVE a verdict — everything except the optional ones
|
|
208
211
|
// nobody ran. Used for provenance and for the dashboard rows, both of which ask "who reviewed this?"
|
|
@@ -223,17 +226,17 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
223
226
|
// 2c. For every verdicted checklist, VERIFY (from the harness's own artifacts) that a real reviewer
|
|
224
227
|
// SUBAGENT actually ran on this branch — the coding agent may not self-certify. Its NAME is not
|
|
225
228
|
// checked; see SubagentProvenanceService.isReviewerRun. Absent CLAUDE_CODE_SESSION_ID this skips with a warning (CI / plain terminal).
|
|
226
|
-
const currentBranch =
|
|
227
|
-
const provenance = this.provenanceEnforcer.enforce(verdicted, currentBranch, repoRoot, config);
|
|
229
|
+
const currentBranch = await this.gitExec.currentBranch(process.cwd());
|
|
230
|
+
const provenance = await this.provenanceEnforcer.enforce(verdicted, currentBranch, repoRoot, config);
|
|
228
231
|
// 2b. The build gate validates the WORKING TREE but we push HEAD — so they MUST be identical.
|
|
229
|
-
this.gitExec.assertCleanTree(repoRoot);
|
|
232
|
+
await this.gitExec.assertCleanTree(repoRoot);
|
|
230
233
|
// 3. Build gate, then post the gated body, then push (that ORDER — see GatedPrPublisher).
|
|
231
234
|
await this.runOrSkipBuildGate(repoRoot, buildAlreadyGreen);
|
|
232
|
-
const base = this.branchNaming.baseBranchName(
|
|
235
|
+
const base = this.branchNaming.baseBranchName(await this.gitExec.currentBranch(process.cwd()));
|
|
233
236
|
process.stdout.write('\n' + SEP + '📋 Dashboard + PR\n' + SEP + '\n');
|
|
234
|
-
const title = this.prTitleFrom(review);
|
|
235
|
-
const input = this.computeDashboardInput(repoRoot, true, review, title, verdicted, scan);
|
|
236
|
-
const result = this.publishAll(repoRoot, base, input, new PrCommentSources(scan, review, provenance));
|
|
237
|
+
const title = await this.prTitleFrom(review);
|
|
238
|
+
const input = await this.computeDashboardInput(repoRoot, true, review, title, verdicted, scan);
|
|
239
|
+
const result = await this.publishAll(repoRoot, base, input, new PrCommentSources(scan, review, provenance));
|
|
237
240
|
this.snapshotPublishedReview(repoRoot, featureName, result);
|
|
238
241
|
// The closing recap + the clickable-link directive, BOTH derived from the real merge outcome.
|
|
239
242
|
// Nothing here may hard-code success: a stranded PR under a green checkmark is how PRs got
|
|
@@ -268,7 +271,7 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
268
271
|
if (alreadyGreen) {
|
|
269
272
|
// `say`, for the same reason the gate's own two lines are: a caller watching for a build needs
|
|
270
273
|
// to be told, live, that there is not going to be one.
|
|
271
|
-
this.stageConsole.say('\n🛠️ Build gate: already green for this commit (stage ② receipt) — skipping the rebuild.\n' + this.skippedBuildLogNote(repoRoot));
|
|
274
|
+
this.stageConsole.say('\n🛠️ Build gate: already green for this commit (stage ② receipt) — skipping the rebuild.\n' + await this.skippedBuildLogNote(repoRoot));
|
|
272
275
|
return;
|
|
273
276
|
}
|
|
274
277
|
await this.buildAffected.runBuildGate(repoRoot, new build_affected_1.BuildGateOptions('🛠️ Build gate (authoritative)', 'pnpm wp-finish-upsert-pr', 'Build failed — no PR created/updated.', build_gate_log_1.FINISH_STAGE));
|
|
@@ -283,17 +286,17 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
283
286
|
* deterministic filename stage ② wrote. Empty string when the file is gone — a log that was reaped or
|
|
284
287
|
* never written must not be named as though a reader could open it.
|
|
285
288
|
*/
|
|
286
|
-
skippedBuildLogNote(repoRoot) {
|
|
287
|
-
const log = this.buildLog.existingLogFor(repoRoot, build_gate_log_1.REVIEW_STAGE);
|
|
289
|
+
async skippedBuildLogNote(repoRoot) {
|
|
290
|
+
const log = await this.buildLog.existingLogFor(repoRoot, build_gate_log_1.REVIEW_STAGE);
|
|
288
291
|
return log === '' ? '' : ` Stage ②'s full build output: ${log}\n`;
|
|
289
292
|
}
|
|
290
293
|
/**
|
|
291
294
|
* The two stage-② preconditions, together: no unvalidated merge, and a receipt proving stage ② ran.
|
|
292
295
|
* Returns true when that receipt covers the CURRENT HEAD, i.e. the build gate can be skipped.
|
|
293
296
|
*/
|
|
294
|
-
assertStageTwoRan(repoRoot) {
|
|
295
|
-
this.assertNoUnvalidatedMerge(repoRoot);
|
|
296
|
-
return this.assertReviewStageRan(repoRoot, this.aiBranchName.getFeatureName(), this.gitOut(['rev-parse', 'HEAD']));
|
|
297
|
+
async assertStageTwoRan(repoRoot) {
|
|
298
|
+
await this.assertNoUnvalidatedMerge(repoRoot);
|
|
299
|
+
return this.assertReviewStageRan(repoRoot, await this.aiBranchName.getFeatureName(), await this.gitOut(['rev-parse', 'HEAD']));
|
|
297
300
|
}
|
|
298
301
|
/**
|
|
299
302
|
* REFUSE while a 3-point merge is still unvalidated — do not finalize it here.
|
|
@@ -307,8 +310,8 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
307
310
|
* running it also builds the merged tree and re-briefs the reviewers against it, which finalizing here
|
|
308
311
|
* never did.
|
|
309
312
|
*/
|
|
310
|
-
assertNoUnvalidatedMerge(repoRoot) {
|
|
311
|
-
const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());
|
|
313
|
+
async assertNoUnvalidatedMerge(repoRoot) {
|
|
314
|
+
const home = this.mergeState.mergeDirFor(repoRoot, await this.aiBranchName.getFeatureName());
|
|
312
315
|
const activeDir = this.mergeState.findActiveMergeRunDir(home);
|
|
313
316
|
const marker = activeDir ? this.mergeState.readMergeMarker(activeDir) : null;
|
|
314
317
|
if (!activeDir || !marker || marker.validated)
|
|
@@ -376,28 +379,28 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
376
379
|
process.stderr.write(`⚠️ Could not snapshot summary.json (non-fatal — the PR is already up): ${error.message}\n`);
|
|
377
380
|
}
|
|
378
381
|
}
|
|
379
|
-
gitOut(args) {
|
|
380
|
-
const result =
|
|
381
|
-
return result.
|
|
382
|
+
async gitOut(args) {
|
|
383
|
+
const result = await this.git.run(args);
|
|
384
|
+
return result.ok ? result.stdout.trim() : '';
|
|
382
385
|
}
|
|
383
386
|
// The user-facing PR title: the AI-authored review.title, or — if omitted — a readable fallback
|
|
384
387
|
// derived from the stable feature name (NEVER the internal `Squash merge of <branch>` commit subject).
|
|
385
|
-
prTitleFrom(review) {
|
|
388
|
+
async prTitleFrom(review) {
|
|
386
389
|
if (review.title !== '')
|
|
387
390
|
return review.title;
|
|
388
|
-
return this.aiBranchName.getFeatureName().replace(/[-/]+/g, ' ').trim();
|
|
391
|
+
return (await this.aiBranchName.getFeatureName()).replace(/[-/]+/g, ' ').trim();
|
|
389
392
|
}
|
|
390
393
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
391
|
-
computeDashboardInput(repoRoot, buildPassed, review, title, required, scan) {
|
|
394
|
+
async computeDashboardInput(repoRoot, buildPassed, review, title, required, scan) {
|
|
392
395
|
const config = (0, rules_config_1.loadAndValidate)(repoRoot).prGate;
|
|
393
|
-
const forkPoint = this.gitOut(['merge-base', 'origin/main', 'HEAD']);
|
|
394
|
-
const featureHead = this.gitOut(['rev-parse', 'HEAD']);
|
|
395
|
-
const mainHead = this.gitOut(['rev-parse', 'origin/main']);
|
|
396
|
+
const forkPoint = await this.gitOut(['merge-base', 'origin/main', 'HEAD']);
|
|
397
|
+
const featureHead = await this.gitOut(['rev-parse', 'HEAD']);
|
|
398
|
+
const mainHead = await this.gitOut(['rev-parse', 'origin/main']);
|
|
396
399
|
const range = `${forkPoint}..${featureHead}`;
|
|
397
|
-
const changedFiles = this.gitOut(['diff', range, '--name-only'])
|
|
400
|
+
const changedFiles = (await this.gitOut(['diff', range, '--name-only']))
|
|
398
401
|
.split('\n')
|
|
399
402
|
.filter((f) => f.trim() !== '');
|
|
400
|
-
const patch = this.gitOut(['diff', range]);
|
|
403
|
+
const patch = await this.gitOut(['diff', range]);
|
|
401
404
|
const gateResults = this.dashboard.computeGateResults(config.gates, changedFiles);
|
|
402
405
|
const disables = this.dashboard.countAddedDisables(patch);
|
|
403
406
|
const rows = this.checklistRows(required, review);
|
|
@@ -484,7 +487,7 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
484
487
|
* checklists configured must still see no comment at all (see ChecklistCommentRenderer).
|
|
485
488
|
*/
|
|
486
489
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
487
|
-
postChecklistComment(repoRoot, prNumber, scan, review, provenance) {
|
|
490
|
+
async postChecklistComment(repoRoot, prNumber, scan, review, provenance) {
|
|
488
491
|
if (prNumber === '' || scan.defined.length === 0)
|
|
489
492
|
return;
|
|
490
493
|
if (!(0, rules_config_1.loadAndValidate)(repoRoot).prGate.checklistComments)
|
|
@@ -493,25 +496,25 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
493
496
|
request.prNumber = prNumber;
|
|
494
497
|
request.marker = checklist_comment_renderer_1.CHECKLIST_COMMENT_MARKER;
|
|
495
498
|
request.body = this.checklistComment.render(this.commentRows(scan, review, provenance), provenance.verified, scan.roster.baseResolved, scan.suppressed.length, false);
|
|
496
|
-
request.payloadDir = (0, rules_config_1.prDirFor)(repoRoot, this.aiBranchName.getFeatureName());
|
|
499
|
+
request.payloadDir = (0, rules_config_1.prDirFor)(repoRoot, await this.aiBranchName.getFeatureName());
|
|
497
500
|
request.payloadName = 'checklist-comment.json';
|
|
498
501
|
request.label = 'checklist review comment';
|
|
499
|
-
this.commentUpserter.upsert(request);
|
|
502
|
+
await this.commentUpserter.upsert(request);
|
|
500
503
|
}
|
|
501
504
|
// The PR, the remote branch, and the local branch all share the one stable feature name. Look up /
|
|
502
505
|
// create / merge against `baseBranch` (baseBranchName tolerates a leftover `…wpN` mid-transition).
|
|
503
506
|
// GatedPrPublisher owns the edit/push/create half and its ORDERING — the gated body goes up before
|
|
504
507
|
// the push, so CI's `synchronize` read cannot see the previous run's token.
|
|
505
|
-
upsertPr(request) {
|
|
508
|
+
async upsertPr(request) {
|
|
506
509
|
const repoRoot = request.repoRoot;
|
|
507
510
|
const baseBranch = request.baseBranch;
|
|
508
511
|
const title = request.title;
|
|
509
512
|
const input = request.input;
|
|
510
|
-
const prDir = (0, rules_config_1.prDirFor)(repoRoot, this.aiBranchName.getFeatureName());
|
|
513
|
+
const prDir = (0, rules_config_1.prDirFor)(repoRoot, await this.aiBranchName.getFeatureName());
|
|
511
514
|
fs.mkdirSync(prDir, { recursive: true });
|
|
512
515
|
const bodyFile = path.join(prDir, 'pr-body.md');
|
|
513
516
|
fs.writeFileSync(bodyFile, request.body + '\n');
|
|
514
|
-
const published = this.publisher.publish(baseBranch, title, bodyFile);
|
|
517
|
+
const published = await this.publisher.publish(baseBranch, title, bodyFile);
|
|
515
518
|
if (published.createFailed) {
|
|
516
519
|
process.stderr.write('⚠️ gh pr create failed — create the PR manually with the body in:\n ' + bodyFile + '\n');
|
|
517
520
|
return new UpsertResult('', '', new pr_merger_1.MergeOutcome(false, false, '⚠️ did NOT merge — there is no PR to merge (gh pr create failed above)', pr_merger_1.MERGE_RESULT_FAILED));
|
|
@@ -521,7 +524,7 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
521
524
|
// explicit --subject would otherwise drop) and the BODY to the compact commit summary, so main's
|
|
522
525
|
// history carries the PR title + risk/flags/link — NOT the internal `Squash merge of <branch>`
|
|
523
526
|
// subject GitHub would inherit from the single squash commit on the branch.
|
|
524
|
-
const ref = this.prRef(baseBranch);
|
|
527
|
+
const ref = await this.prRef(baseBranch);
|
|
525
528
|
const subject = ref.number !== '' ? `${title} (#${ref.number})` : title;
|
|
526
529
|
/*
|
|
527
530
|
* THE INVARIANT: the merge body IS the PR description, byte for byte.
|
|
@@ -540,7 +543,7 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
540
543
|
*/
|
|
541
544
|
const finalBody = this.dashboard.renderPrBody(input, ref.url) + request.tokenSuffix;
|
|
542
545
|
if (finalBody !== request.body)
|
|
543
|
-
this.backfillPrBody(ref.number, bodyFile, finalBody);
|
|
546
|
+
await this.backfillPrBody(ref.number, bodyFile, finalBody);
|
|
544
547
|
// The DURABLE copy of these bytes is the PR description published above; this is a throwaway
|
|
545
548
|
// file because `--body-file` takes a path. `wp-land-pr` reads the description back from GitHub,
|
|
546
549
|
// so nothing here has to survive the process (see decisions/0005).
|
|
@@ -551,7 +554,7 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
551
554
|
// rules-config that has no such field) reaches PrMerger as '' and is treated as "do not merge".
|
|
552
555
|
const mergeMode = (0, rules_config_1.loadAndValidate)(repoRoot).prGate.mergeMode ?? '';
|
|
553
556
|
// `false`: this caller is POLICY-driven — only a config that really says AUTO merges here.
|
|
554
|
-
const outcome = this.prMerger.merge(baseBranch, subject, mergeBodyFile, new pr_merger_1.MergeIntent(mergeMode, false));
|
|
557
|
+
const outcome = await this.prMerger.merge(baseBranch, subject, mergeBodyFile, new pr_merger_1.MergeIntent(mergeMode, false));
|
|
555
558
|
return new UpsertResult(ref.number !== '' ? ref.number : num, ref.url, outcome);
|
|
556
559
|
}
|
|
557
560
|
/**
|
|
@@ -571,9 +574,9 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
571
574
|
* earns its own name: these four steps have a REQUIRED order, and the comment explaining that order
|
|
572
575
|
* belongs with them rather than inside a method that also loads config and runs a build gate.
|
|
573
576
|
*/
|
|
574
|
-
publishAll(repoRoot, base, input, sources) {
|
|
577
|
+
async publishAll(repoRoot, base, input, sources) {
|
|
575
578
|
const gateSalt = (0, rules_config_1.loadAndValidate)(repoRoot).prGate.gateSalt;
|
|
576
|
-
const headSha = this.gitOut(['rev-parse', 'HEAD']);
|
|
579
|
+
const headSha = await this.gitOut(['rev-parse', 'HEAD']);
|
|
577
580
|
const upsert = new PrUpsertRequest(input);
|
|
578
581
|
upsert.repoRoot = repoRoot;
|
|
579
582
|
upsert.baseBranch = base;
|
|
@@ -581,22 +584,22 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
581
584
|
upsert.tokenSuffix = this.gateTokenBody(gateSalt, headSha);
|
|
582
585
|
// `existingPrUrl` is '' only for a brand-new PR — there is no URL to self-link to until
|
|
583
586
|
// `gh pr create` returns one, and upsertPr back-fills it the moment it does.
|
|
584
|
-
upsert.body = this.dashboard.renderPrBody(input, this.existingPrUrl(base)) + upsert.tokenSuffix;
|
|
587
|
+
upsert.body = this.dashboard.renderPrBody(input, await this.existingPrUrl(base)) + upsert.tokenSuffix;
|
|
585
588
|
// Rendering above already refused a stray closing reference; say out loud what merging WILL close.
|
|
586
589
|
// `say`: a wrong closesIssue must be noticed BEFORE landing, so this may not end up only in the log.
|
|
587
590
|
for (const warning of new issue_references_1.IssueReferences().closeWarnings(input.review.addressesIssues))
|
|
588
591
|
this.stageConsole.say(`${warning}\n`);
|
|
589
|
-
const result = this.upsertPr(upsert);
|
|
592
|
+
const result = await this.upsertPr(upsert);
|
|
590
593
|
// In the order the PR body's pointer promises: full dashboard 1st, reviewer output 2nd. Both are
|
|
591
594
|
// idempotent by hidden marker and both non-fatal — the PR is up by now, so a `gh` hiccup on a
|
|
592
595
|
// comment must not turn a finished run into a failed one.
|
|
593
|
-
this.postDetailComment(repoRoot, result.prNumber, input);
|
|
594
|
-
this.postChecklistComment(repoRoot, result.prNumber, sources.scan, sources.review, sources.provenance);
|
|
596
|
+
await this.postDetailComment(repoRoot, result.prNumber, input);
|
|
597
|
+
await this.postChecklistComment(repoRoot, result.prNumber, sources.scan, sources.review, sources.provenance);
|
|
595
598
|
// Having just written the description AS the commit body, make sure GitHub will actually use it.
|
|
596
599
|
// Here rather than anywhere earlier because it is about what happens to the artifact we just
|
|
597
600
|
// published, and it must run on EVERY repo — including mergeMode=NONE ones that never reach
|
|
598
601
|
// PrMerger, which are exactly the repos where a UI merge decides what main's history says.
|
|
599
|
-
this.squashSettings.ensure();
|
|
602
|
+
await this.squashSettings.ensure();
|
|
600
603
|
return result;
|
|
601
604
|
}
|
|
602
605
|
/**
|
|
@@ -608,14 +611,12 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
608
611
|
* next `wp-finish-upsert-pr` writes it (by then the URL is known before publishing, so it goes up with
|
|
609
612
|
* the body). The merge body still gets the linked version regardless: it is filed from `finalBody`.
|
|
610
613
|
*/
|
|
611
|
-
backfillPrBody(prNumber, bodyFile, finalBody) {
|
|
614
|
+
async backfillPrBody(prNumber, bodyFile, finalBody) {
|
|
612
615
|
if (prNumber === '')
|
|
613
616
|
return;
|
|
614
617
|
fs.writeFileSync(bodyFile, finalBody + '\n');
|
|
615
|
-
const res =
|
|
616
|
-
|
|
617
|
-
});
|
|
618
|
-
if (res.status !== 0) {
|
|
618
|
+
const res = await this.processes.run('gh', ['pr', 'edit', prNumber, '--body-file', bodyFile]);
|
|
619
|
+
if (!res.ok) {
|
|
619
620
|
process.stderr.write("⚠️ Could not add the PR's own link to its description (non-fatal — the PR and the gate\n" + ' token are already up). The next wp-finish-upsert-pr writes it.\n');
|
|
620
621
|
return;
|
|
621
622
|
}
|
|
@@ -626,8 +627,8 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
626
627
|
* description can carry its own link on the first render. Only a brand-new PR gets '' (and then
|
|
627
628
|
* {@link backfillPrBody} fixes it up after `gh pr create` returns a URL).
|
|
628
629
|
*/
|
|
629
|
-
existingPrUrl(baseBranch) {
|
|
630
|
-
return this.prRef(baseBranch).url;
|
|
630
|
+
async existingPrUrl(baseBranch) {
|
|
631
|
+
return (await this.prRef(baseBranch)).url;
|
|
631
632
|
}
|
|
632
633
|
/**
|
|
633
634
|
* The 1st PR comment: the FULL dashboard — every row including the green ones, the whole summary, the
|
|
@@ -639,7 +640,7 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
639
640
|
* a 1st comment holding the detail. A pointer to a comment that does not exist is worse than no
|
|
640
641
|
* pointer. Non-fatal — the PR is already up, and the description alone is a complete, readable record.
|
|
641
642
|
*/
|
|
642
|
-
postDetailComment(repoRoot, prNumber, input) {
|
|
643
|
+
async postDetailComment(repoRoot, prNumber, input) {
|
|
643
644
|
if (prNumber === '')
|
|
644
645
|
return;
|
|
645
646
|
const request = new pr_comment_upserter_1.PrCommentRequest();
|
|
@@ -647,19 +648,19 @@ let FinishUpsertPrCommand = class FinishUpsertPrCommand {
|
|
|
647
648
|
request.marker = dashboard_1.DETAIL_COMMENT_MARKER;
|
|
648
649
|
const detail = this.dashboard.renderDetailComment(input);
|
|
649
650
|
request.body = dashboard_1.DETAIL_COMMENT_MARKER + '\n' + detail;
|
|
650
|
-
request.payloadDir = (0, rules_config_1.prDirFor)(repoRoot, this.aiBranchName.getFeatureName());
|
|
651
|
+
request.payloadDir = (0, rules_config_1.prDirFor)(repoRoot, await this.aiBranchName.getFeatureName());
|
|
651
652
|
request.payloadName = 'detail-comment.json';
|
|
652
653
|
request.label = 'full dashboard comment';
|
|
653
|
-
this.commentUpserter.upsert(request);
|
|
654
|
+
await this.commentUpserter.upsert(request);
|
|
654
655
|
}
|
|
655
656
|
// The PR's number + web URL (for the merge subject `(#N)` and the commit-body back-link). Both ''
|
|
656
657
|
// if it can't be resolved. Rendered via jq into one tab-separated line so no JSON parsing is needed.
|
|
657
|
-
prRef(baseBranch) {
|
|
658
|
-
const result =
|
|
659
|
-
if (result.
|
|
658
|
+
async prRef(baseBranch) {
|
|
659
|
+
const result = await this.processes.run('gh', ['pr', 'view', baseBranch, '--json', 'number,url', '--jq', '"\\(.number)\\t\\(.url)"']);
|
|
660
|
+
if (!result.ok) {
|
|
660
661
|
return new PrRef('', '');
|
|
661
662
|
}
|
|
662
|
-
const parts =
|
|
663
|
+
const parts = result.stdout.trim().split('\t');
|
|
663
664
|
return new PrRef(parts[0] ?? '', parts[1] ?? '');
|
|
664
665
|
}
|
|
665
666
|
};
|
|
@@ -690,6 +691,8 @@ exports.FinishUpsertPrCommand = FinishUpsertPrCommand = tslib_1.__decorate([
|
|
|
690
691
|
squash_settings_enforcer_1.SquashSettingsEnforcer,
|
|
691
692
|
stage_output_log_1.StageOutputLog,
|
|
692
693
|
hotfix_redirect_1.HotfixRedirect,
|
|
693
|
-
review_round_state_1.ReviewRoundStateService
|
|
694
|
+
review_round_state_1.ReviewRoundStateService,
|
|
695
|
+
tooling_common_1.GitProcessApi,
|
|
696
|
+
tooling_common_1.NativeProcessApi])
|
|
694
697
|
], FinishUpsertPrCommand);
|
|
695
698
|
//# sourceMappingURL=finish-upsert-pr-command.js.map
|