@webpieces/pr-gate 0.4.985 → 0.4.986
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/build-push-dev-command.d.ts +23 -5
- package/src/scripts/commands/build-push-dev-command.js +33 -8
- package/src/scripts/commands/build-push-dev-command.js.map +1 -1
- package/src/scripts/pr-gate-cli-app.js +1 -1
- package/src/scripts/pr-gate-cli-app.js.map +1 -1
- package/src/scripts/workflow/build-gate-log.d.ts +1 -0
- package/src/scripts/workflow/build-gate-log.js +5 -1
- package/src/scripts/workflow/build-gate-log.js.map +1 -1
- package/src/scripts/workflow/dev-build.d.ts +8 -5
- package/src/scripts/workflow/dev-build.js +11 -7
- package/src/scripts/workflow/dev-build.js.map +1 -1
- package/src/scripts/workflow/dev-copy-on-main.d.ts +6 -4
- package/src/scripts/workflow/dev-copy-on-main.js +8 -6
- package/src/scripts/workflow/dev-copy-on-main.js.map +1 -1
- package/src/scripts/workflow/dev-resolve-runner.d.ts +19 -4
- package/src/scripts/workflow/dev-resolve-runner.js +50 -12
- package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
- package/src/scripts/workflow/landed-copy-resolver.d.ts +56 -0
- package/src/scripts/workflow/landed-copy-resolver.js +141 -0
- package/src/scripts/workflow/landed-copy-resolver.js.map +1 -0
|
@@ -9,16 +9,19 @@ const build_gate_log_1 = require("./build-gate-log");
|
|
|
9
9
|
const dev_deploy_refs_1 = require("./dev-deploy-refs");
|
|
10
10
|
const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
|
|
11
11
|
/** The example printed when the key is missing. An example, never a fallback: nothing ever RUNS it. */
|
|
12
|
-
exports.EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected
|
|
12
|
+
exports.EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected -t build test --base=origin/dev --head=HEAD';
|
|
13
13
|
/**
|
|
14
14
|
* The dev-scoped build (#1397): `commands.push-dev.buildCommand`, run through the SAME build gate as
|
|
15
15
|
* `wp-build` and the PR gate (`BuildAffected.runBuildGateWith`) — one log-file capture, one heartbeat, one
|
|
16
16
|
* ledger row pair, one failure rendering. Only the command and the log name (`build-dev.log`) differ.
|
|
17
17
|
*
|
|
18
|
-
* WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`:
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: `wp-build-push-dev` runs BOTH (#1405). The
|
|
19
|
+
* PR gate's build runs first, on the feature branch alone, with the code rules judging it against main. This
|
|
20
|
+
* one runs on the merge with `dev` and answers a different question — does everyone's code still compile and
|
|
21
|
+
* pass tests together — so it should compile and test ONLY, affected vs `origin/dev`. It must not run the
|
|
22
|
+
* code rules (`architecture:validate-code`, i.e. an nx `ci` target): that tree holds every other developer's
|
|
23
|
+
* copy, and diffed against main their code is judged as the publisher's change. The two are different
|
|
24
|
+
* builds, so they are two keys.
|
|
22
25
|
*
|
|
23
26
|
* NO DEFAULT, deliberately (`.claude/rules/no-rule-defaults.md`): which build vouches for a dev publish is
|
|
24
27
|
* the consumer's decision. Missing ⇒ the command refuses before it touches anything, naming the key and
|
|
@@ -40,8 +43,9 @@ let DevBuild = class DevBuild {
|
|
|
40
43
|
+ `${rules_config_1.WP_BUILD_PUSH_DEV} builds your copy merged with origin/dev before wp-finish-push-dev publishes it.\n`
|
|
41
44
|
+ 'WHICH build is this repo\'s decision, so there is no default.\n'
|
|
42
45
|
+ 'Nothing was merged, built or published.\n\n'
|
|
43
|
-
+ 'Add this to webpieces.config.json, inside "commands", choosing a command that
|
|
44
|
-
+ 'differs from origin/dev
|
|
46
|
+
+ 'Add this to webpieces.config.json, inside "commands", choosing a command that compiles and tests\n'
|
|
47
|
+
+ 'only what differs from origin/dev — and runs NO code rules (no `ci` target): the rules already judged\n'
|
|
48
|
+
+ 'your branch against main, and on this tree they would judge every other developer\'s copy as yours:\n\n'
|
|
45
49
|
+ ` "push-dev": { "buildCommand": "${exports.EXAMPLE_DEV_BUILD_COMMAND}" }\n`);
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-build.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-build.ts"],"names":[],"mappings":";;;;AAAA,0DAA0E;AAC1E,yCAA2D;AAE3D,qDAAmE;AACnE,qDAAmD;AACnD,uDAAkD;AAElD,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,uGAAuG;AAC1F,QAAA,yBAAyB,GAAG,
|
|
1
|
+
{"version":3,"file":"dev-build.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-build.ts"],"names":[],"mappings":";;;;AAAA,0DAA0E;AAC1E,yCAA2D;AAE3D,qDAAmE;AACnE,qDAAmD;AACnD,uDAAkD;AAElD,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,uGAAuG;AAC1F,QAAA,yBAAyB,GAAG,8DAA8D,CAAC;AAExG;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEI;IACA;IAFrB,YACqB,aAA4B,EAC5B,IAAmB;QADnB,kBAAa,GAAb,aAAa,CAAe;QAC5B,SAAI,GAAJ,IAAI,CAAe;IACrC,CAAC;IAEJ,4GAA4G;IAC5G,OAAO,CAAC,QAAgB;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,UAAU,CAAC;QAC5E,MAAM,IAAI,2BAAY,CAAC,CAAC,EACpB,IAAI,GAAG,GAAG,GAAG,wDAAwD,GAAG,GAAG,GAAG,IAAI;cAChF,GAAG,gCAAiB,oFAAoF;cACxG,iEAAiE;cACjE,6CAA6C;cAC7C,oGAAoG;cACpG,yGAAyG;cACzG,yGAAyG;cACzG,oCAAoC,iCAAyB,OAAO,CAAC,CAAC;IAChF,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,QAAgB,EAAE,YAAoB;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,iCAAgB,CAC9E,iDAAiD,EACjD,YAAY,EACZ,2CAA2C,EAC3C,gCAAe,CAClB,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAnCY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGD,8BAAa;QACtB,+BAAa;GAH/B,QAAQ,CAmCpB","sourcesContent":["import { CliExitError, WP_BUILD_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { BuildAffected, BuildGateOptions } from './build-affected';\nimport { DEV_BUILD_STAGE } from './build-gate-log';\nimport { DevDeployRefs } from './dev-deploy-refs';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The example printed when the key is missing. An example, never a fallback: nothing ever RUNS it. */\nexport const EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected -t build test --base=origin/dev --head=HEAD';\n\n/**\n * The dev-scoped build (#1397): `commands.push-dev.buildCommand`, run through the SAME build gate as\n * `wp-build` and the PR gate (`BuildAffected.runBuildGateWith`) — one log-file capture, one heartbeat, one\n * ledger row pair, one failure rendering. Only the command and the log name (`build-dev.log`) differ.\n *\n * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: `wp-build-push-dev` runs BOTH (#1405). The\n * PR gate's build runs first, on the feature branch alone, with the code rules judging it against main. This\n * one runs on the merge with `dev` and answers a different question — does everyone's code still compile and\n * pass tests together — so it should compile and test ONLY, affected vs `origin/dev`. It must not run the\n * code rules (`architecture:validate-code`, i.e. an nx `ci` target): that tree holds every other developer's\n * copy, and diffed against main their code is judged as the publisher's change. The two are different\n * builds, so they are two keys.\n *\n * NO DEFAULT, deliberately (`.claude/rules/no-rule-defaults.md`): which build vouches for a dev publish is\n * the consumer's decision. Missing ⇒ the command refuses before it touches anything, naming the key and\n * printing the entry to paste.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevBuild {\n constructor(\n private readonly buildAffected: BuildAffected,\n private readonly refs: DevDeployRefs,\n ) {}\n\n /** The configured command, or the refusal naming the key. Called BEFORE any git write, so it fails fast. */\n command(repoRoot: string): string {\n const configured = this.refs.devBuildCommand(repoRoot);\n if (configured !== undefined && configured.trim() !== '') return configured;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ `commands.push-dev.buildCommand` is not configured\\n' + SEP + '\\n'\n + `${WP_BUILD_PUSH_DEV} builds your copy merged with origin/dev before wp-finish-push-dev publishes it.\\n`\n + 'WHICH build is this repo\\'s decision, so there is no default.\\n'\n + 'Nothing was merged, built or published.\\n\\n'\n + 'Add this to webpieces.config.json, inside \"commands\", choosing a command that compiles and tests\\n'\n + 'only what differs from origin/dev — and runs NO code rules (no `ci` target): the rules already judged\\n'\n + 'your branch against main, and on this tree they would judge every other developer\\'s copy as yours:\\n\\n'\n + ` \"push-dev\": { \"buildCommand\": \"${EXAMPLE_DEV_BUILD_COMMAND}\" }\\n`);\n }\n\n /**\n * Run the dev build on the CURRENT checkout. Throws CliExitError on a red build, with the `FullLog :`\n * pointer, exactly like `wp-build`. `rerunCommand` is what the failure text tells the reader to run\n * after fixing it.\n */\n run(repoRoot: string, rerunCommand: string): Promise<void> {\n const command = this.command(repoRoot);\n return this.buildAffected.runBuildGateWith(repoRoot, command, new BuildGateOptions(\n '🛠️ dev build (commands.push-dev.buildCommand)',\n rerunCommand,\n 'Dev build failed — nothing was published.',\n DEV_BUILD_STAGE,\n ));\n }\n}\n"]}
|
|
@@ -22,7 +22,8 @@ export declare class MergedPr {
|
|
|
22
22
|
constructor(num: string, mergedAt: string);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Answers "is this dev copy already on `origin/main`?" for `wp-finish-push-dev --remove` (#1401)
|
|
25
|
+
* Answers "is this dev copy already on `origin/main`?" for `wp-finish-push-dev --remove` (#1401), and for
|
|
26
|
+
* `wp-build-push-dev`'s automatic resolution of conflicts caused only by landed copies (#1405).
|
|
26
27
|
*
|
|
27
28
|
* WHY: developers ran `--remove` after their PR landed, as a "done, clean up" habit. On a repo that composes
|
|
28
29
|
* `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and
|
|
@@ -40,9 +41,10 @@ export declare class DevCopyOnMain {
|
|
|
40
41
|
constructor(gitExec: GitExec, processes: NativeProcessApi);
|
|
41
42
|
landing(repoRoot: string, copyRef: string): Promise<DevCopyLanding>;
|
|
42
43
|
/**
|
|
43
|
-
* The merged PR whose head was `branch`, or null.
|
|
44
|
-
*
|
|
45
|
-
* already decided
|
|
44
|
+
* The merged PR whose head was `branch`, or null. A `gh` that is missing, unauthenticated or offline
|
|
45
|
+
* yields null rather than an error, and null is always the SAFE answer: for `--remove` it only drops a
|
|
46
|
+
* decoration from the refusal (the content check above has already decided), and for the landed-copy
|
|
47
|
+
* resolution (#1405) it means "not proven landed", so the conflict is left for the developer.
|
|
46
48
|
*/
|
|
47
49
|
mergedPr(repoRoot: string, branch: string): Promise<MergedPr | null>;
|
|
48
50
|
private names;
|
|
@@ -42,7 +42,8 @@ exports.MergedPr = MergedPr;
|
|
|
42
42
|
// `<number> <mergedAt>` as the --jq below prints it; an empty list prints `null null`, which does not match.
|
|
43
43
|
const PR_LINE = /^(\d+) (\S+)$/;
|
|
44
44
|
/**
|
|
45
|
-
* Answers "is this dev copy already on `origin/main`?" for `wp-finish-push-dev --remove` (#1401)
|
|
45
|
+
* Answers "is this dev copy already on `origin/main`?" for `wp-finish-push-dev --remove` (#1401), and for
|
|
46
|
+
* `wp-build-push-dev`'s automatic resolution of conflicts caused only by landed copies (#1405).
|
|
46
47
|
*
|
|
47
48
|
* WHY: developers ran `--remove` after their PR landed, as a "done, clean up" habit. On a repo that composes
|
|
48
49
|
* `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and
|
|
@@ -63,15 +64,16 @@ let DevCopyOnMain = class DevCopyOnMain {
|
|
|
63
64
|
}
|
|
64
65
|
async landing(repoRoot, copyRef) {
|
|
65
66
|
const copy = `refs/remotes/origin/${copyRef}`;
|
|
66
|
-
const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`], `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy})
|
|
67
|
-
const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy], `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy})
|
|
67
|
+
const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`], `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy}).`);
|
|
68
|
+
const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy], `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy}).`));
|
|
68
69
|
const landed = changed.filter((f) => !stillDiffer.has(f));
|
|
69
70
|
return new DevCopyLanding(changed, landed);
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
|
-
* The merged PR whose head was `branch`, or null.
|
|
73
|
-
*
|
|
74
|
-
* already decided
|
|
73
|
+
* The merged PR whose head was `branch`, or null. A `gh` that is missing, unauthenticated or offline
|
|
74
|
+
* yields null rather than an error, and null is always the SAFE answer: for `--remove` it only drops a
|
|
75
|
+
* decoration from the refusal (the content check above has already decided), and for the landed-copy
|
|
76
|
+
* resolution (#1405) it means "not proven landed", so the conflict is left for the developer.
|
|
75
77
|
*/
|
|
76
78
|
async mergedPr(repoRoot, branch) {
|
|
77
79
|
const result = await this.processes.run('gh', [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-copy-on-main.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-copy-on-main.ts"],"names":[],"mappings":";;;;AAAA,8DAA6D;AAC7D,yCAA2D;AAE3D,yCAAqC;AAErC,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C;;;;;GAKG;AACH,MAAa,cAAc;IAEV;IACA;IAFb,YACa,OAAiB,EACjB,MAAgB;QADhB,YAAO,GAAP,OAAO,CAAU;QACjB,WAAM,GAAN,MAAM,CAAU;IAC1B,CAAC;IAEJ,8GAA8G;IAC9G,WAAW;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACtD,CAAC;IAED,kEAAkE;IAClE,YAAY;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACzD,CAAC;CACJ;AAfD,wCAeC;AAED,wFAAwF;AACxF,MAAa,QAAQ;IAEJ;IACA;IAFb,YACa,GAAW,EACX,QAAgB;QADhB,QAAG,GAAH,GAAG,CAAQ;QACX,aAAQ,GAAR,QAAQ,CAAQ;IAC1B,CAAC;CACP;AALD,4BAKC;AAED,6GAA6G;AAC7G,MAAM,OAAO,GAAG,eAAe,CAAC;AAEhC
|
|
1
|
+
{"version":3,"file":"dev-copy-on-main.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-copy-on-main.ts"],"names":[],"mappings":";;;;AAAA,8DAA6D;AAC7D,yCAA2D;AAE3D,yCAAqC;AAErC,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C;;;;;GAKG;AACH,MAAa,cAAc;IAEV;IACA;IAFb,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C,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACzG,CAAC;CACJ,CAAA;AArCY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGP,kBAAO;QACL,iCAAgB;GAHvC,aAAa,CAqCzB","sourcesContent":["import { NativeProcessApi } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from './git-exec';\n\nconst MAIN_REF = 'refs/remotes/origin/main';\n\n/**\n * How much of one dev copy is already on `origin/main`. Data-only per CLAUDE.md.\n *\n * `changed` is every file the copy changes relative to its merge-base with `origin/main`; `landed` is the\n * subset whose content on `origin/main` is now identical to the copy's.\n */\nexport class DevCopyLanding {\n constructor(\n readonly changed: string[],\n readonly landed: string[],\n ) {}\n\n /** Every file the copy changes already has the copy's content on main — removing it takes nothing off dev. */\n fullyOnMain(): boolean {\n return this.landed.length === this.changed.length;\n }\n\n /** Some, but not all, of the copy's files are already on main. */\n partlyOnMain(): boolean {\n return this.landed.length > 0 && !this.fullyOnMain();\n }\n}\n\n/** The merged PR a copy's branch landed through, for the refusal message. Data-only. */\nexport class MergedPr {\n constructor(\n readonly num: string,\n readonly mergedAt: string,\n ) {}\n}\n\n// `<number> <mergedAt>` as the --jq below prints it; an empty list prints `null null`, which does not match.\nconst PR_LINE = /^(\\d+) (\\S+)$/;\n\n/**\n * Answers \"is this dev copy already on `origin/main`?\" for `wp-finish-push-dev --remove` (#1401), and for\n * `wp-build-push-dev`'s automatic resolution of conflicts caused only by landed copies (#1405).\n *\n * WHY: developers ran `--remove` after their PR landed, as a \"done, clean up\" habit. On a repo that composes\n * `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and\n * still triggers a full recompose that can redeploy every service. Only rolling back a copy that broke dev is\n * a real reason to remove.\n *\n * HOW: a pure content check, no GitHub dependency. The files the copy changes since its merge-base with\n * `origin/main` (`git diff A...B`), minus the files where `origin/main` and the copy still differ\n * (`git diff A B`), are the files already landed. Both refs must already be fetched. `--no-renames` so a\n * rename counts both its old and new path rather than hiding the deletion.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevCopyOnMain {\n constructor(\n private readonly gitExec: GitExec,\n private readonly processes: NativeProcessApi,\n ) {}\n\n async landing(repoRoot: string, copyRef: string): Promise<DevCopyLanding> {\n const copy = `refs/remotes/origin/${copyRef}`;\n const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`],\n `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy}).`);\n const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy],\n `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy}).`));\n const landed = changed.filter((f: string): boolean => !stillDiffer.has(f));\n return new DevCopyLanding(changed, landed);\n }\n\n /**\n * The merged PR whose head was `branch`, or null. A `gh` that is missing, unauthenticated or offline\n * yields null rather than an error, and null is always the SAFE answer: for `--remove` it only drops a\n * decoration from the refusal (the content check above has already decided), and for the landed-copy\n * resolution (#1405) it means \"not proven landed\", so the conflict is left for the developer.\n */\n async mergedPr(repoRoot: string, branch: string): Promise<MergedPr | null> {\n const result = await this.processes.run('gh', [\n 'pr', 'list', '--head', branch, '--state', 'merged', '--limit', '1',\n '--json', 'number,mergedAt', '--jq', '.[0] | \"\\\\(.number) \\\\(.mergedAt)\"',\n ], repoRoot);\n if (!result.ok) return null;\n const match = PR_LINE.exec(result.stdout.trim());\n if (match === null) return null;\n return new MergedPr(match[1], match[2]);\n }\n\n private async names(repoRoot: string, revs: string[], failMsg: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['-C', repoRoot, 'diff', '--name-only', '--no-renames', ...revs], repoRoot, failMsg);\n return out.split('\\n').map((l: string): string => l.trim()).filter((l: string): boolean => l !== '');\n }\n}\n"]}
|
|
@@ -5,13 +5,16 @@ import { DevDeployRefs } from './dev-deploy-refs';
|
|
|
5
5
|
import { PushDevState, PushDevStateStore } from './push-dev-state';
|
|
6
6
|
import { DevBuild } from './dev-build';
|
|
7
7
|
import { VerifiedDevCopyStore } from './verified-dev-copy';
|
|
8
|
+
import { LandedCopyResolver } from './landed-copy-resolver';
|
|
8
9
|
/**
|
|
9
10
|
* The subject prefix of the ONE commit this flow writes onto a copy: the recorded conflict resolution.
|
|
10
11
|
*/
|
|
11
12
|
export declare const RESOLUTION_SUBJECT = "Dev-deploy: conflict resolution for";
|
|
12
13
|
/**
|
|
13
|
-
* The engine behind `wp-build-push-dev` (#1403): merge `origin/<devBranch>` into a
|
|
14
|
-
*
|
|
14
|
+
* The engine behind `wp-build-push-dev`'s check against dev (#1403): merge `origin/<devBranch>` into a
|
|
15
|
+
* THROWAWAY branch, take the publisher's side on conflicts caused only by copies already on main (#1405),
|
|
16
|
+
* stop on any other conflict, `pnpm install`, run the dev build (compile + tests, no code rules), and record
|
|
17
|
+
* the copy `wp-finish-push-dev` publishes.
|
|
15
18
|
*
|
|
16
19
|
* ONE class owns every git WRITE of the check, and that is a hard requirement rather than tidiness:
|
|
17
20
|
* `redirect-how-to-merge-main` blocks `git merge` in every form INCLUDING `--continue`, and
|
|
@@ -30,12 +33,24 @@ export declare class DevResolveRunner {
|
|
|
30
33
|
private readonly verified;
|
|
31
34
|
private readonly devBuild;
|
|
32
35
|
private readonly processes;
|
|
33
|
-
|
|
36
|
+
private readonly landedCopies;
|
|
37
|
+
constructor(gitExec: GitExec, refs: DevDeployRefs, store: PushDevStateStore, verified: VerifiedDevCopyStore, devBuild: DevBuild, processes: NativeProcessApi, landedCopies: LandedCopyResolver);
|
|
34
38
|
/**
|
|
35
39
|
* Start the check: park on a throwaway branch at the feature head, merge `origin/<devBranch>` into it,
|
|
36
40
|
* and either halt on a conflict or go straight on to install, build and record.
|
|
37
41
|
*/
|
|
38
|
-
start(repoRoot: string, state: PushDevState): Promise<void>;
|
|
42
|
+
start(repoRoot: string, cfg: DevDeployConfig, state: PushDevState): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* The merge conflicted. First take the publisher's side on every file whose dev side comes ONLY from
|
|
45
|
+
* copies already on main (#1405, LandedCopyResolver); when that was every conflicted file, commit the
|
|
46
|
+
* merge and carry on. Otherwise halt on what is left — the developer's job, as before.
|
|
47
|
+
*/
|
|
48
|
+
private resolveLandedOrHalt;
|
|
49
|
+
/**
|
|
50
|
+
* The merge failed WITHOUT leaving a conflicted file (an untracked file in the way, a broken ref, …).
|
|
51
|
+
* There is nothing to resolve, so the checkout goes back to the feature branch and git's own words say why.
|
|
52
|
+
*/
|
|
53
|
+
private mergeFailed;
|
|
39
54
|
/** Resume after the conflicted files were resolved and `git add`-ed: commit the merge, then finish. */
|
|
40
55
|
resume(repoRoot: string, state: PushDevState): Promise<void>;
|
|
41
56
|
/**
|
|
@@ -11,14 +11,17 @@ const dev_deploy_refs_1 = require("./dev-deploy-refs");
|
|
|
11
11
|
const push_dev_state_1 = require("./push-dev-state");
|
|
12
12
|
const dev_build_1 = require("./dev-build");
|
|
13
13
|
const verified_dev_copy_1 = require("./verified-dev-copy");
|
|
14
|
+
const landed_copy_resolver_1 = require("./landed-copy-resolver");
|
|
14
15
|
const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
|
|
15
16
|
/**
|
|
16
17
|
* The subject prefix of the ONE commit this flow writes onto a copy: the recorded conflict resolution.
|
|
17
18
|
*/
|
|
18
19
|
exports.RESOLUTION_SUBJECT = 'Dev-deploy: conflict resolution for';
|
|
19
20
|
/**
|
|
20
|
-
* The engine behind `wp-build-push-dev` (#1403): merge `origin/<devBranch>` into a
|
|
21
|
-
*
|
|
21
|
+
* The engine behind `wp-build-push-dev`'s check against dev (#1403): merge `origin/<devBranch>` into a
|
|
22
|
+
* THROWAWAY branch, take the publisher's side on conflicts caused only by copies already on main (#1405),
|
|
23
|
+
* stop on any other conflict, `pnpm install`, run the dev build (compile + tests, no code rules), and record
|
|
24
|
+
* the copy `wp-finish-push-dev` publishes.
|
|
22
25
|
*
|
|
23
26
|
* ONE class owns every git WRITE of the check, and that is a hard requirement rather than tidiness:
|
|
24
27
|
* `redirect-how-to-merge-main` blocks `git merge` in every form INCLUDING `--continue`, and
|
|
@@ -37,19 +40,21 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
37
40
|
verified;
|
|
38
41
|
devBuild;
|
|
39
42
|
processes;
|
|
40
|
-
|
|
43
|
+
landedCopies;
|
|
44
|
+
constructor(gitExec, refs, store, verified, devBuild, processes, landedCopies) {
|
|
41
45
|
this.gitExec = gitExec;
|
|
42
46
|
this.refs = refs;
|
|
43
47
|
this.store = store;
|
|
44
48
|
this.verified = verified;
|
|
45
49
|
this.devBuild = devBuild;
|
|
46
50
|
this.processes = processes;
|
|
51
|
+
this.landedCopies = landedCopies;
|
|
47
52
|
}
|
|
48
53
|
/**
|
|
49
54
|
* Start the check: park on a throwaway branch at the feature head, merge `origin/<devBranch>` into it,
|
|
50
55
|
* and either halt on a conflict or go straight on to install, build and record.
|
|
51
56
|
*/
|
|
52
|
-
async start(repoRoot, state) {
|
|
57
|
+
async start(repoRoot, cfg, state) {
|
|
53
58
|
await this.refs.fetchCopies(repoRoot, [state.devBranch]);
|
|
54
59
|
// Pinned to a SHA: the resolution is recorded on top of exactly what was merged, and stage ③
|
|
55
60
|
// refuses to publish when the feature branch has moved since.
|
|
@@ -59,10 +64,38 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
59
64
|
const merged = await this.gitExec.tryGit(['-C', repoRoot, 'merge', '--no-ff', '--no-edit', '-m',
|
|
60
65
|
`Dev-deploy: merge ${state.devBranch} into ${state.targetRef}`, `refs/remotes/origin/${state.devBranch}`], repoRoot);
|
|
61
66
|
if (!merged.ok)
|
|
62
|
-
await this.
|
|
67
|
+
await this.resolveLandedOrHalt(repoRoot, cfg, state, merged);
|
|
63
68
|
process.stdout.write(` ✓ merged origin/${state.devBranch}\n`);
|
|
64
69
|
await this.finish(repoRoot, state);
|
|
65
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* The merge conflicted. First take the publisher's side on every file whose dev side comes ONLY from
|
|
73
|
+
* copies already on main (#1405, LandedCopyResolver); when that was every conflicted file, commit the
|
|
74
|
+
* merge and carry on. Otherwise halt on what is left — the developer's job, as before.
|
|
75
|
+
*/
|
|
76
|
+
async resolveLandedOrHalt(repoRoot, cfg, state, merged) {
|
|
77
|
+
const conflicted = await this.unmergedPaths(repoRoot);
|
|
78
|
+
if (conflicted.length === 0)
|
|
79
|
+
await this.mergeFailed(repoRoot, state, merged);
|
|
80
|
+
const resolution = await this.landedCopies.resolve(repoRoot, cfg, conflicted);
|
|
81
|
+
if (resolution.remaining.length > 0)
|
|
82
|
+
await this.halt(repoRoot, state, resolution);
|
|
83
|
+
process.stdout.write(this.landedCopies.describe(resolution));
|
|
84
|
+
await this.gitExec.runGitChecked(['-C', repoRoot, 'commit', '--no-edit'], `Failed to commit the merge with origin/${state.devBranch} after resolving the landed copies' conflicts`);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The merge failed WITHOUT leaving a conflicted file (an untracked file in the way, a broken ref, …).
|
|
88
|
+
* There is nothing to resolve, so the checkout goes back to the feature branch and git's own words say why.
|
|
89
|
+
*/
|
|
90
|
+
async mergeFailed(repoRoot, state, merged) {
|
|
91
|
+
await this.restore(repoRoot, state);
|
|
92
|
+
throw new rules_config_1.CliExitError(1, '\n' + SEP + `⛔ Merging origin/${state.devBranch} failed — and nothing conflicted\n` + SEP + '\n'
|
|
93
|
+
+ `git merge exited ${String(merged.status)} without leaving a conflicted file, so there is nothing to resolve.\n`
|
|
94
|
+
+ 'What git said:\n'
|
|
95
|
+
+ `${(merged.stderr + merged.stdout).trim()}\n\n`
|
|
96
|
+
+ `Nothing was built, recorded or published; you are back on \`${state.originalBranch}\`. Fix what git\n`
|
|
97
|
+
+ `reported, then re-run: ${rules_config_1.WP_BUILD_PUSH_DEV}\n`);
|
|
98
|
+
}
|
|
66
99
|
/** Resume after the conflicted files were resolved and `git add`-ed: commit the merge, then finish. */
|
|
67
100
|
async resume(repoRoot, state) {
|
|
68
101
|
await this.assertNoUnmergedPaths(repoRoot);
|
|
@@ -83,10 +116,11 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
83
116
|
+ `Nothing was published, and your feature branch is untouched.\n`);
|
|
84
117
|
}
|
|
85
118
|
/** Stop with the conflicted files listed and the ONE command that continues. Exit 2 = "your turn". */
|
|
86
|
-
async halt(repoRoot, state) {
|
|
87
|
-
const conflicted =
|
|
119
|
+
async halt(repoRoot, state, landed) {
|
|
120
|
+
const conflicted = landed.remaining;
|
|
88
121
|
// Remembered so the finish records EXACTLY these files as the resolution — and nothing else the
|
|
89
|
-
// merge brought in, which is other developers' work.
|
|
122
|
+
// merge brought in, which is other developers' work. Files resolved to the publisher's side
|
|
123
|
+
// automatically are not among them: they hold what the base already has, so there is nothing to record.
|
|
90
124
|
state.resolvedPaths = conflicted;
|
|
91
125
|
this.store.write(repoRoot, state);
|
|
92
126
|
throw new rules_config_1.CliExitError(2, '\n' + SEP + `⚠️ CONFLICT merging origin/${state.devBranch}\n` + SEP + '\n'
|
|
@@ -94,6 +128,7 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
94
128
|
+ 'can reach your feature branch or your PR, which is exactly why the resolution happens over here.\n\n'
|
|
95
129
|
+ 'Resolve these files (edit until no conflict markers remain, then `git add` each one):\n'
|
|
96
130
|
+ conflicted.map((f) => ` ${f}`).join('\n') + '\n'
|
|
131
|
+
+ this.landedCopies.describe(landed)
|
|
97
132
|
+ '\nThen run ONE of:\n'
|
|
98
133
|
+ ` ${rules_config_1.WP_BUILD_PUSH_DEV} ← commit the resolution, pnpm install, run the dev build\n`
|
|
99
134
|
+ ` ${rules_config_1.WP_BUILD_PUSH_DEV} --abort ← throw it away and go back to \`${state.originalBranch}\`\n\n`
|
|
@@ -233,9 +268,11 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
233
268
|
announce(cfg, state) {
|
|
234
269
|
return '\n' + SEP + `🔎 Checking ${state.targetRef} against origin/${cfg.devBranch}\n` + SEP + '\n'
|
|
235
270
|
+ `Merging origin/${cfg.devBranch} into the throwaway branch \`${state.tmpBranch}\`, then running \`pnpm install\`\n`
|
|
236
|
-
+ 'and `commands.push-dev.buildCommand`
|
|
237
|
-
+
|
|
238
|
-
+ '
|
|
271
|
+
+ 'and `commands.push-dev.buildCommand` (compile + tests only — the code rules already judged your branch\n'
|
|
272
|
+
+ 'against main, and must never judge the other copies on dev) on the merged tree. A conflict whose dev\n'
|
|
273
|
+
+ 'side comes only from copies already on origin/main takes your side automatically.\n'
|
|
274
|
+
+ `Nothing is published here — when both pass, ${rules_config_1.WP_FINISH_PUSH_DEV} publishes your branch, plus ONE\n`
|
|
275
|
+
+ 'commit holding any resolved files. The merge itself is never published.\n'
|
|
239
276
|
+ `Your feature branch \`${state.originalBranch}\` is not touched by any of this.\n\n`;
|
|
240
277
|
}
|
|
241
278
|
};
|
|
@@ -247,6 +284,7 @@ exports.DevResolveRunner = DevResolveRunner = tslib_1.__decorate([
|
|
|
247
284
|
push_dev_state_1.PushDevStateStore,
|
|
248
285
|
verified_dev_copy_1.VerifiedDevCopyStore,
|
|
249
286
|
dev_build_1.DevBuild,
|
|
250
|
-
tooling_common_1.NativeProcessApi
|
|
287
|
+
tooling_common_1.NativeProcessApi,
|
|
288
|
+
landed_copy_resolver_1.LandedCopyResolver])
|
|
251
289
|
], DevResolveRunner);
|
|
252
290
|
//# sourceMappingURL=dev-resolve-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-resolve-runner.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-resolve-runner.ts"],"names":[],"mappings":";;;;AAAA,0DAA+G;AAC/G,8DAA6D;AAC7D,iEAA6D;AAC7D,yCAA2D;AAE3D,yCAAqC;AACrC,uDAAkD;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C,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM;cACnE,yBAAyB,gCAAiB,YAAY,CAAC,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,MAAc;QACvB,OAAO,GAAG,MAAM,YAAY,CAAC;IACjC,CAAC;IAED,0EAA0E;IAC1E,QAAQ,CAAC,GAAoB,EAAE,KAAmB;QAC9C,OAAO,IAAI,GAAG,GAAG,GAAG,eAAe,KAAK,CAAC,SAAS,mBAAmB,GAAG,CAAC,SAAS,IAAI,GAAG,GAAG,GAAG,IAAI;cAC7F,kBAAkB,GAAG,CAAC,SAAS,gCAAgC,KAAK,CAAC,SAAS,qCAAqC;cACnH,wGAAwG;cACxG,GAAG,iCAAkB,iFAAiF;cACtG,8BAA8B;cAC9B,yBAAyB,KAAK,CAAC,cAAc,uCAAuC,CAAC;IAC/F,CAAC;CACJ,CAAA;AArOY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGP,kBAAO;QACV,+BAAa;QACZ,kCAAiB;QACd,wCAAoB;QACpB,oBAAQ;QACP,iCAAgB;GAPvC,gBAAgB,CAqO5B","sourcesContent":["import { CliExitError, DevDeployConfig, WP_BUILD_PUSH_DEV, WP_FINISH_PUSH_DEV } from '@webpieces/rules-config';\nimport { NativeProcessApi } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from './git-exec';\nimport { DevDeployRefs } from './dev-deploy-refs';\nimport { PushDevState, PushDevStateStore } from './push-dev-state';\nimport { DevBuild } from './dev-build';\nimport { VerifiedDevCopy, VerifiedDevCopyStore } from './verified-dev-copy';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The subject prefix of the ONE commit this flow writes onto a copy: the recorded conflict resolution.\n */\nexport const RESOLUTION_SUBJECT = 'Dev-deploy: conflict resolution for';\n\n/**\n * The engine behind `wp-build-push-dev` (#1403): merge `origin/<devBranch>` into a THROWAWAY branch, stop\n * on a conflict, `pnpm install`, run the dev build, and record the copy `wp-finish-push-dev` publishes.\n *\n * ONE class owns every git WRITE of the check, and that is a hard requirement rather than tidiness:\n * `redirect-how-to-merge-main` blocks `git merge` in every form INCLUDING `--continue`, and\n * `merge-in-progress-guard` blocks `git commit`. So an AI cannot be told \"now run `git commit`\" or\n * \"`git merge --continue`\" — those instructions are unrunnable by the only party reading them. The command\n * owns the merge and the commits (as child processes the hooks never see); the AI's entire job is editing\n * the conflicted files and `git add`-ing them, neither of which is blocked.\n *\n * It NEVER writes to the feature branch: every merge lands on a throwaway that is deleted at the end, so no\n * other developer's commits can reach the PR head even if the check is abandoned halfway.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevResolveRunner {\n constructor(\n private readonly gitExec: GitExec,\n private readonly refs: DevDeployRefs,\n private readonly store: PushDevStateStore,\n private readonly verified: VerifiedDevCopyStore,\n private readonly devBuild: DevBuild,\n private readonly processes: NativeProcessApi,\n ) {}\n\n /**\n * Start the check: park on a throwaway branch at the feature head, merge `origin/<devBranch>` into it,\n * and either halt on a conflict or go straight on to install, build and record.\n */\n async start(repoRoot: string, state: PushDevState): Promise<void> {\n await this.refs.fetchCopies(repoRoot, [state.devBranch]);\n // Pinned to a SHA: the resolution is recorded on top of exactly what was merged, and stage ③\n // refuses to publish when the feature branch has moved since.\n state.baseSha = await this.refs.headSha(repoRoot, 'HEAD');\n this.store.write(repoRoot, state);\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'checkout', '-B', state.tmpBranch, 'HEAD'],\n `Failed to create the throwaway branch ${state.tmpBranch}`);\n const merged = await this.gitExec.tryGit(\n ['-C', repoRoot, 'merge', '--no-ff', '--no-edit', '-m',\n `Dev-deploy: merge ${state.devBranch} into ${state.targetRef}`, `refs/remotes/origin/${state.devBranch}`],\n repoRoot);\n if (!merged.ok) await this.halt(repoRoot, state);\n process.stdout.write(` ✓ merged origin/${state.devBranch}\\n`);\n await this.finish(repoRoot, state);\n }\n\n /** Resume after the conflicted files were resolved and `git add`-ed: commit the merge, then finish. */\n async resume(repoRoot: string, state: PushDevState): Promise<void> {\n await this.assertNoUnmergedPaths(repoRoot);\n await this.gitExec.assertNoUntracked(repoRoot);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'add', '-u'], 'Failed to stage the resolved files (git add -u)');\n await this.gitExec.runGitChecked(['-C', repoRoot, 'commit', '--no-edit'],\n `Failed to commit the resolution of the merge with origin/${state.devBranch}`);\n process.stdout.write(`✅ Committed the resolution of the merge with origin/${state.devBranch}.\\n`);\n await this.finish(repoRoot, state);\n }\n\n /**\n * Throw the whole check away: undo any halted merge, go back to the original branch, delete the\n * throwaway branch and the state file. Nothing verified, nothing on the feature branch.\n */\n async abort(repoRoot: string, state: PushDevState): Promise<void> {\n await this.restore(repoRoot, state);\n process.stdout.write(\n '\\n' + SEP + '🛑 Dev-deploy check aborted\\n' + SEP + '\\n'\n + `You are back on \\`${state.originalBranch}\\`; \\`${state.tmpBranch}\\` and the state file are gone.\\n`\n + `Nothing was published, and your feature branch is untouched.\\n`);\n }\n\n /** Stop with the conflicted files listed and the ONE command that continues. Exit 2 = \"your turn\". */\n private async halt(repoRoot: string, state: PushDevState): Promise<never> {\n const conflicted = await this.unmergedPaths(repoRoot);\n // Remembered so the finish records EXACTLY these files as the resolution — and nothing else the\n // merge brought in, which is other developers' work.\n state.resolvedPaths = conflicted;\n this.store.write(repoRoot, state);\n throw new CliExitError(2,\n '\\n' + SEP + `⚠️ CONFLICT merging origin/${state.devBranch}\\n` + SEP + '\\n'\n + `You are on the throwaway branch \\`${state.tmpBranch}\\` — NOT \\`${state.originalBranch}\\`. Nothing here\\n`\n + 'can reach your feature branch or your PR, which is exactly why the resolution happens over here.\\n\\n'\n + 'Resolve these files (edit until no conflict markers remain, then `git add` each one):\\n'\n + conflicted.map((f: string): string => ` ${f}`).join('\\n') + '\\n'\n + '\\nThen run ONE of:\\n'\n + ` ${WP_BUILD_PUSH_DEV} ← commit the resolution, pnpm install, run the dev build\\n`\n + ` ${WP_BUILD_PUSH_DEV} --abort ← throw it away and go back to \\`${state.originalBranch}\\`\\n\\n`\n + 'Do NOT run `git merge --continue`, `git commit` or `git push` yourself — they are blocked, and\\n'\n + 'the commands above do them for you.\\n');\n }\n\n /**\n * The merge is complete. Install and build the MERGED tree, then turn the throwaway into the copy and\n * record it for `wp-finish-push-dev`.\n *\n * `pnpm install` runs AFTER the merge, never before: other copies already on dev can add workspace\n * packages main does not have yet, so the feature branch's `node_modules` does not link the merged\n * tree (#1403 — a 30-commits-behind branch failed six minutes into its build on exactly that).\n */\n private async finish(repoRoot: string, state: PushDevState): Promise<void> {\n await this.onThrowaway(repoRoot, state, (): Promise<void> => this.install(repoRoot, state));\n await this.onThrowaway(repoRoot, state, (): Promise<void> => this.devBuild.run(repoRoot, WP_BUILD_PUSH_DEV));\n // The install may rewrite the lockfile on the throwaway; drop that before the throwaway moves.\n await this.gitExec.runGitChecked(['-C', repoRoot, 'reset', '--hard', 'HEAD'],\n `Failed to discard what pnpm install changed on ${state.tmpBranch}`);\n await this.recordResolution(repoRoot, state);\n const copySha = await this.refs.headSha(repoRoot, state.tmpBranch);\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'update-ref', this.verified.keepRef(state.originalBranch), copySha],\n `Failed to keep the verified copy ${copySha.slice(0, 8)} reachable`);\n const devSha = await this.refs.headSha(repoRoot, `refs/remotes/origin/${state.devBranch}`);\n this.verified.write(repoRoot, new VerifiedDevCopy(\n state.originalBranch, state.baseSha, copySha, state.targetRef, state.leaseSha, devSha));\n await this.restore(repoRoot, state);\n process.stdout.write(this.verifiedBanner(state, devSha));\n }\n\n private async install(repoRoot: string, state: PushDevState): Promise<void> {\n process.stdout.write(`\\nRunning pnpm install on the merged throwaway \\`${state.tmpBranch}\\`.\\n`);\n const result = await this.processes.passThrough('pnpm', ['install'], repoRoot);\n if (result.ok) return;\n throw new CliExitError(1,\n '\\n' + SEP + `⛔ pnpm install failed on the merge with origin/${state.devBranch}\\n` + SEP + '\\n'\n + `\\`pnpm install\\` exited ${String(result.code)} on the merged tree (its output is above). No build ran and\\n`\n + `nothing was verified; you are back on \\`${state.originalBranch}\\`. Fix what it reported, then re-run:\\n`\n + ` ${WP_BUILD_PUSH_DEV}\\n`);\n }\n\n /**\n * Run one step on the throwaway. On a failure, put the checkout back first — the fix belongs on the\n * feature branch, and a developer left parked on a throwaway would make the next `wp-*` command act on\n * the wrong branch — then let the step's own failure (a build's carries its `FullLog :` pointer) reach\n * the top-level handler unchanged.\n */\n private async onThrowaway(repoRoot: string, state: PushDevState, step: () => Promise<void>): Promise<void> {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: the checkout must be restored whether or not the step passed; the step's own error is re-thrown unchanged\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await step();\n } catch (err: unknown) {\n const error = toError(err);\n await this.restore(repoRoot, state);\n throw error;\n }\n }\n\n /**\n * Turn the throwaway into the copy: the base sha plus, when anything conflicted, ONE commit that sets\n * each resolved file to its resolved content.\n *\n * The merge is used for the conflict check and the build only, and is never published. Publishing it\n * would make every other copy an ancestor of this one, so a later `--remove` of that copy would leave\n * its commits on dev through ours. The resolution commit has exactly one parent, the base, so the only\n * thing it can carry of anybody else's work is the text of the hunks that were resolved — content,\n * never history.\n */\n private async recordResolution(repoRoot: string, state: PushDevState): Promise<void> {\n const merged = await this.refs.headSha(repoRoot, state.tmpBranch);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'checkout', '-B', state.tmpBranch, state.baseSha],\n `Failed to move ${state.tmpBranch} back to ${state.baseSha.slice(0, 8)} to record the resolution`);\n if (state.resolvedPaths.length === 0) return;\n for (const file of state.resolvedPaths) {\n const inMerge = await this.gitExec.tryGit(['-C', repoRoot, 'cat-file', '-e', `${merged}:${file}`], repoRoot);\n await this.gitExec.runGitChecked(\n inMerge.ok\n ? ['-C', repoRoot, 'checkout', merged, '--', file]\n : ['-C', repoRoot, 'rm', '-q', '--ignore-unmatch', '--', file],\n `Failed to record the resolution of ${file}`);\n }\n // Resolved to exactly what the base already had (\"keep mine\") is a resolution with nothing to record.\n const unchanged = await this.gitExec.tryGit(['-C', repoRoot, 'diff', '--cached', '--quiet'], repoRoot);\n if (unchanged.ok) return;\n await this.gitExec.runGitChecked(['-C', repoRoot, 'commit', '-m',\n `${RESOLUTION_SUBJECT} ${state.targetRef}\\n\\n`\n + 'This commit carries only the files that conflicted and were resolved:\\n'\n + state.resolvedPaths.map((f: string): string => ` ${f}`).join('\\n') + '\\n'],\n `Failed to commit the recorded resolution for ${state.targetRef}`);\n }\n\n /** Back to the original branch; any halted merge, the throwaway and the state file are gone. */\n private async restore(repoRoot: string, state: PushDevState): Promise<void> {\n // Only ever on the throwaway: a reset anywhere else could destroy somebody's uncommitted work.\n // Both allowed to fail: there is no merge to abort once it completed, and nothing to reset on a\n // clean tree. Neither is an error — the rest of the teardown must still run.\n if (await this.gitExec.currentBranch(repoRoot) === state.tmpBranch) {\n await this.gitExec.tryGit(['-C', repoRoot, 'merge', '--abort'], repoRoot);\n await this.gitExec.tryGit(['-C', repoRoot, 'reset', '--hard', 'HEAD'], repoRoot);\n }\n await this.gitExec.runGitChecked(['-C', repoRoot, 'checkout', state.originalBranch],\n `Failed to return to ${state.originalBranch}`);\n await this.gitExec.tryGit(['-C', repoRoot, 'branch', '-D', state.tmpBranch], repoRoot);\n this.store.clear(repoRoot);\n }\n\n private verifiedBanner(state: PushDevState, devSha: string): string {\n const what = state.resolvedPaths.length === 0\n ? 'your branch exactly as it is'\n : `your branch plus ONE commit recording the resolution of ${String(state.resolvedPaths.length)} file(s) — no merge, so no other copy becomes part of its history`;\n return '\\n' + SEP + `✅ ${state.targetRef} is verified against origin/${state.devBranch}\\n` + SEP + '\\n'\n + `It merges with origin/${state.devBranch} (${devSha.slice(0, 8)}), pnpm install ran on the merged tree, and the dev\\n`\n + `build is green. The copy to publish is ${what}.\\n`\n + `You are back on \\`${state.originalBranch}\\`, which this check never modified.\\n\\n`\n + `▶ NEXT run: ${WP_FINISH_PUSH_DEV}\\n`\n + ` It publishes the verified copy as \\`${state.targetRef}\\`. It refuses if \\`${state.originalBranch}\\`\\n`\n + ' moves before then — a new commit means a new check.\\n';\n }\n\n /** Conflicted (unmerged-in-index) paths. Empty once every one has been resolved and `git add`ed. */\n private async unmergedPaths(repoRoot: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['-C', repoRoot, 'diff', '--name-only', '--diff-filter=U'], repoRoot,\n 'Failed to list the conflicted files (git diff --name-only --diff-filter=U).');\n return out.split('\\n').filter((l: string): boolean => l.trim() !== '');\n }\n\n // The gate on resuming: refuse (and re-print the list) while anything is still unmerged.\n private async assertNoUnmergedPaths(repoRoot: string): Promise<void> {\n const conflicted = await this.unmergedPaths(repoRoot);\n if (conflicted.length === 0) return;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ Conflicts are NOT resolved yet\\n' + SEP + '\\n'\n + `${WP_BUILD_PUSH_DEV} commits the resolution — it cannot write one for you. These files are still\\n`\n + 'unmerged (edit until no conflict markers remain, then `git add` each one):\\n'\n + conflicted.map((f: string): string => ` ${f}`).join('\\n') + '\\n\\n'\n + `Give up instead with: ${WP_BUILD_PUSH_DEV} --abort\\n`);\n }\n\n /**\n * The name of the throwaway branch for a check of `branch`.\n *\n * Suffixed rather than prefixed, matching the existing `<feature>Squash` / `<feature>PreMerge<n>`\n * convention — and deliberately NOT inside the dev namespace, which holds REMOTE copies only.\n */\n tmpBranchFor(branch: string): string {\n return `${branch}DevResolve`;\n }\n\n /** The banner `wp-build-push-dev` prints before its check against dev. */\n announce(cfg: DevDeployConfig, state: PushDevState): string {\n return '\\n' + SEP + `🔎 Checking ${state.targetRef} against origin/${cfg.devBranch}\\n` + SEP + '\\n'\n + `Merging origin/${cfg.devBranch} into the throwaway branch \\`${state.tmpBranch}\\`, then running \\`pnpm install\\`\\n`\n + 'and `commands.push-dev.buildCommand` on the merged tree. Nothing is published here — when both pass,\\n'\n + `${WP_FINISH_PUSH_DEV} publishes your branch, plus ONE commit holding any resolved files. The merge\\n`\n + 'itself is never published.\\n'\n + `Your feature branch \\`${state.originalBranch}\\` is not touched by any of this.\\n\\n`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dev-resolve-runner.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-resolve-runner.ts"],"names":[],"mappings":";;;;AAAA,0DAA+G;AAC/G,8DAA6D;AAC7D,iEAA6D;AAC7D,yCAA2D;AAE3D,yCAAiD;AACjD,uDAAkD;AAClD,qDAAmE;AACnE,2CAAuC;AACvC,2DAA4E;AAC5E,iEAA8E;AAE9E,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;GAEG;AACU,QAAA,kBAAkB,GAAG,qCAAqC,CAAC;AAExE;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEJ;IACA;IACA;IACA;IACA;IACA;IACA;IAPrB,YACqB,OAAgB,EAChB,IAAmB,EACnB,KAAwB,EACxB,QAA8B,EAC9B,QAAkB,EAClB,SAA2B,EAC3B,YAAgC;QANhC,YAAO,GAAP,OAAO,CAAS;QAChB,SAAI,GAAJ,IAAI,CAAe;QACnB,UAAK,GAAL,KAAK,CAAmB;QACxB,aAAQ,GAAR,QAAQ,CAAsB;QAC9B,aAAQ,GAAR,QAAQ,CAAU;QAClB,cAAS,GAAT,SAAS,CAAkB;QAC3B,iBAAY,GAAZ,YAAY,CAAoB;IAClD,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,GAAoB,EAAE,KAAmB;QACnE,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QACzD,6FAA6F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cAC3E,yBAAyB,KAAK,CAAC,cAAc,uCAAuC,CAAC;IAC/F,CAAC;CACJ,CAAA;AA1QY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGP,kBAAO;QACV,+BAAa;QACZ,kCAAiB;QACd,wCAAoB;QACpB,oBAAQ;QACP,iCAAgB;QACb,yCAAkB;GAR5C,gBAAgB,CA0Q5B","sourcesContent":["import { CliExitError, DevDeployConfig, WP_BUILD_PUSH_DEV, WP_FINISH_PUSH_DEV } from '@webpieces/rules-config';\nimport { NativeProcessApi } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec, GitOutcome } from './git-exec';\nimport { DevDeployRefs } from './dev-deploy-refs';\nimport { PushDevState, PushDevStateStore } from './push-dev-state';\nimport { DevBuild } from './dev-build';\nimport { VerifiedDevCopy, VerifiedDevCopyStore } from './verified-dev-copy';\nimport { LandedCopyResolver, LandedResolution } from './landed-copy-resolver';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The subject prefix of the ONE commit this flow writes onto a copy: the recorded conflict resolution.\n */\nexport const RESOLUTION_SUBJECT = 'Dev-deploy: conflict resolution for';\n\n/**\n * The engine behind `wp-build-push-dev`'s check against dev (#1403): merge `origin/<devBranch>` into a\n * THROWAWAY branch, take the publisher's side on conflicts caused only by copies already on main (#1405),\n * stop on any other conflict, `pnpm install`, run the dev build (compile + tests, no code rules), and record\n * the copy `wp-finish-push-dev` publishes.\n *\n * ONE class owns every git WRITE of the check, and that is a hard requirement rather than tidiness:\n * `redirect-how-to-merge-main` blocks `git merge` in every form INCLUDING `--continue`, and\n * `merge-in-progress-guard` blocks `git commit`. So an AI cannot be told \"now run `git commit`\" or\n * \"`git merge --continue`\" — those instructions are unrunnable by the only party reading them. The command\n * owns the merge and the commits (as child processes the hooks never see); the AI's entire job is editing\n * the conflicted files and `git add`-ing them, neither of which is blocked.\n *\n * It NEVER writes to the feature branch: every merge lands on a throwaway that is deleted at the end, so no\n * other developer's commits can reach the PR head even if the check is abandoned halfway.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevResolveRunner {\n constructor(\n private readonly gitExec: GitExec,\n private readonly refs: DevDeployRefs,\n private readonly store: PushDevStateStore,\n private readonly verified: VerifiedDevCopyStore,\n private readonly devBuild: DevBuild,\n private readonly processes: NativeProcessApi,\n private readonly landedCopies: LandedCopyResolver,\n ) {}\n\n /**\n * Start the check: park on a throwaway branch at the feature head, merge `origin/<devBranch>` into it,\n * and either halt on a conflict or go straight on to install, build and record.\n */\n async start(repoRoot: string, cfg: DevDeployConfig, state: PushDevState): Promise<void> {\n await this.refs.fetchCopies(repoRoot, [state.devBranch]);\n // Pinned to a SHA: the resolution is recorded on top of exactly what was merged, and stage ③\n // refuses to publish when the feature branch has moved since.\n state.baseSha = await this.refs.headSha(repoRoot, 'HEAD');\n this.store.write(repoRoot, state);\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'checkout', '-B', state.tmpBranch, 'HEAD'],\n `Failed to create the throwaway branch ${state.tmpBranch}`);\n const merged = await this.gitExec.tryGit(\n ['-C', repoRoot, 'merge', '--no-ff', '--no-edit', '-m',\n `Dev-deploy: merge ${state.devBranch} into ${state.targetRef}`, `refs/remotes/origin/${state.devBranch}`],\n repoRoot);\n if (!merged.ok) await this.resolveLandedOrHalt(repoRoot, cfg, state, merged);\n process.stdout.write(` ✓ merged origin/${state.devBranch}\\n`);\n await this.finish(repoRoot, state);\n }\n\n /**\n * The merge conflicted. First take the publisher's side on every file whose dev side comes ONLY from\n * copies already on main (#1405, LandedCopyResolver); when that was every conflicted file, commit the\n * merge and carry on. Otherwise halt on what is left — the developer's job, as before.\n */\n private async resolveLandedOrHalt(\n repoRoot: string, cfg: DevDeployConfig, state: PushDevState, merged: GitOutcome,\n ): Promise<void> {\n const conflicted = await this.unmergedPaths(repoRoot);\n if (conflicted.length === 0) await this.mergeFailed(repoRoot, state, merged);\n const resolution = await this.landedCopies.resolve(repoRoot, cfg, conflicted);\n if (resolution.remaining.length > 0) await this.halt(repoRoot, state, resolution);\n process.stdout.write(this.landedCopies.describe(resolution));\n await this.gitExec.runGitChecked(['-C', repoRoot, 'commit', '--no-edit'],\n `Failed to commit the merge with origin/${state.devBranch} after resolving the landed copies' conflicts`);\n }\n\n /**\n * The merge failed WITHOUT leaving a conflicted file (an untracked file in the way, a broken ref, …).\n * There is nothing to resolve, so the checkout goes back to the feature branch and git's own words say why.\n */\n private async mergeFailed(repoRoot: string, state: PushDevState, merged: GitOutcome): Promise<never> {\n await this.restore(repoRoot, state);\n throw new CliExitError(1,\n '\\n' + SEP + `⛔ Merging origin/${state.devBranch} failed — and nothing conflicted\\n` + SEP + '\\n'\n + `git merge exited ${String(merged.status)} without leaving a conflicted file, so there is nothing to resolve.\\n`\n + 'What git said:\\n'\n + `${(merged.stderr + merged.stdout).trim()}\\n\\n`\n + `Nothing was built, recorded or published; you are back on \\`${state.originalBranch}\\`. Fix what git\\n`\n + `reported, then re-run: ${WP_BUILD_PUSH_DEV}\\n`);\n }\n\n /** Resume after the conflicted files were resolved and `git add`-ed: commit the merge, then finish. */\n async resume(repoRoot: string, state: PushDevState): Promise<void> {\n await this.assertNoUnmergedPaths(repoRoot);\n await this.gitExec.assertNoUntracked(repoRoot);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'add', '-u'], 'Failed to stage the resolved files (git add -u)');\n await this.gitExec.runGitChecked(['-C', repoRoot, 'commit', '--no-edit'],\n `Failed to commit the resolution of the merge with origin/${state.devBranch}`);\n process.stdout.write(`✅ Committed the resolution of the merge with origin/${state.devBranch}.\\n`);\n await this.finish(repoRoot, state);\n }\n\n /**\n * Throw the whole check away: undo any halted merge, go back to the original branch, delete the\n * throwaway branch and the state file. Nothing verified, nothing on the feature branch.\n */\n async abort(repoRoot: string, state: PushDevState): Promise<void> {\n await this.restore(repoRoot, state);\n process.stdout.write(\n '\\n' + SEP + '🛑 Dev-deploy check aborted\\n' + SEP + '\\n'\n + `You are back on \\`${state.originalBranch}\\`; \\`${state.tmpBranch}\\` and the state file are gone.\\n`\n + `Nothing was published, and your feature branch is untouched.\\n`);\n }\n\n /** Stop with the conflicted files listed and the ONE command that continues. Exit 2 = \"your turn\". */\n private async halt(repoRoot: string, state: PushDevState, landed: LandedResolution): Promise<never> {\n const conflicted = landed.remaining;\n // Remembered so the finish records EXACTLY these files as the resolution — and nothing else the\n // merge brought in, which is other developers' work. Files resolved to the publisher's side\n // automatically are not among them: they hold what the base already has, so there is nothing to record.\n state.resolvedPaths = conflicted;\n this.store.write(repoRoot, state);\n throw new CliExitError(2,\n '\\n' + SEP + `⚠️ CONFLICT merging origin/${state.devBranch}\\n` + SEP + '\\n'\n + `You are on the throwaway branch \\`${state.tmpBranch}\\` — NOT \\`${state.originalBranch}\\`. Nothing here\\n`\n + 'can reach your feature branch or your PR, which is exactly why the resolution happens over here.\\n\\n'\n + 'Resolve these files (edit until no conflict markers remain, then `git add` each one):\\n'\n + conflicted.map((f: string): string => ` ${f}`).join('\\n') + '\\n'\n + this.landedCopies.describe(landed)\n + '\\nThen run ONE of:\\n'\n + ` ${WP_BUILD_PUSH_DEV} ← commit the resolution, pnpm install, run the dev build\\n`\n + ` ${WP_BUILD_PUSH_DEV} --abort ← throw it away and go back to \\`${state.originalBranch}\\`\\n\\n`\n + 'Do NOT run `git merge --continue`, `git commit` or `git push` yourself — they are blocked, and\\n'\n + 'the commands above do them for you.\\n');\n }\n\n /**\n * The merge is complete. Install and build the MERGED tree, then turn the throwaway into the copy and\n * record it for `wp-finish-push-dev`.\n *\n * `pnpm install` runs AFTER the merge, never before: other copies already on dev can add workspace\n * packages main does not have yet, so the feature branch's `node_modules` does not link the merged\n * tree (#1403 — a 30-commits-behind branch failed six minutes into its build on exactly that).\n */\n private async finish(repoRoot: string, state: PushDevState): Promise<void> {\n await this.onThrowaway(repoRoot, state, (): Promise<void> => this.install(repoRoot, state));\n await this.onThrowaway(repoRoot, state, (): Promise<void> => this.devBuild.run(repoRoot, WP_BUILD_PUSH_DEV));\n // The install may rewrite the lockfile on the throwaway; drop that before the throwaway moves.\n await this.gitExec.runGitChecked(['-C', repoRoot, 'reset', '--hard', 'HEAD'],\n `Failed to discard what pnpm install changed on ${state.tmpBranch}`);\n await this.recordResolution(repoRoot, state);\n const copySha = await this.refs.headSha(repoRoot, state.tmpBranch);\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'update-ref', this.verified.keepRef(state.originalBranch), copySha],\n `Failed to keep the verified copy ${copySha.slice(0, 8)} reachable`);\n const devSha = await this.refs.headSha(repoRoot, `refs/remotes/origin/${state.devBranch}`);\n this.verified.write(repoRoot, new VerifiedDevCopy(\n state.originalBranch, state.baseSha, copySha, state.targetRef, state.leaseSha, devSha));\n await this.restore(repoRoot, state);\n process.stdout.write(this.verifiedBanner(state, devSha));\n }\n\n private async install(repoRoot: string, state: PushDevState): Promise<void> {\n process.stdout.write(`\\nRunning pnpm install on the merged throwaway \\`${state.tmpBranch}\\`.\\n`);\n const result = await this.processes.passThrough('pnpm', ['install'], repoRoot);\n if (result.ok) return;\n throw new CliExitError(1,\n '\\n' + SEP + `⛔ pnpm install failed on the merge with origin/${state.devBranch}\\n` + SEP + '\\n'\n + `\\`pnpm install\\` exited ${String(result.code)} on the merged tree (its output is above). No build ran and\\n`\n + `nothing was verified; you are back on \\`${state.originalBranch}\\`. Fix what it reported, then re-run:\\n`\n + ` ${WP_BUILD_PUSH_DEV}\\n`);\n }\n\n /**\n * Run one step on the throwaway. On a failure, put the checkout back first — the fix belongs on the\n * feature branch, and a developer left parked on a throwaway would make the next `wp-*` command act on\n * the wrong branch — then let the step's own failure (a build's carries its `FullLog :` pointer) reach\n * the top-level handler unchanged.\n */\n private async onThrowaway(repoRoot: string, state: PushDevState, step: () => Promise<void>): Promise<void> {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: the checkout must be restored whether or not the step passed; the step's own error is re-thrown unchanged\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await step();\n } catch (err: unknown) {\n const error = toError(err);\n await this.restore(repoRoot, state);\n throw error;\n }\n }\n\n /**\n * Turn the throwaway into the copy: the base sha plus, when anything conflicted, ONE commit that sets\n * each resolved file to its resolved content.\n *\n * The merge is used for the conflict check and the build only, and is never published. Publishing it\n * would make every other copy an ancestor of this one, so a later `--remove` of that copy would leave\n * its commits on dev through ours. The resolution commit has exactly one parent, the base, so the only\n * thing it can carry of anybody else's work is the text of the hunks that were resolved — content,\n * never history.\n */\n private async recordResolution(repoRoot: string, state: PushDevState): Promise<void> {\n const merged = await this.refs.headSha(repoRoot, state.tmpBranch);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'checkout', '-B', state.tmpBranch, state.baseSha],\n `Failed to move ${state.tmpBranch} back to ${state.baseSha.slice(0, 8)} to record the resolution`);\n if (state.resolvedPaths.length === 0) return;\n for (const file of state.resolvedPaths) {\n const inMerge = await this.gitExec.tryGit(['-C', repoRoot, 'cat-file', '-e', `${merged}:${file}`], repoRoot);\n await this.gitExec.runGitChecked(\n inMerge.ok\n ? ['-C', repoRoot, 'checkout', merged, '--', file]\n : ['-C', repoRoot, 'rm', '-q', '--ignore-unmatch', '--', file],\n `Failed to record the resolution of ${file}`);\n }\n // Resolved to exactly what the base already had (\"keep mine\") is a resolution with nothing to record.\n const unchanged = await this.gitExec.tryGit(['-C', repoRoot, 'diff', '--cached', '--quiet'], repoRoot);\n if (unchanged.ok) return;\n await this.gitExec.runGitChecked(['-C', repoRoot, 'commit', '-m',\n `${RESOLUTION_SUBJECT} ${state.targetRef}\\n\\n`\n + 'This commit carries only the files that conflicted and were resolved:\\n'\n + state.resolvedPaths.map((f: string): string => ` ${f}`).join('\\n') + '\\n'],\n `Failed to commit the recorded resolution for ${state.targetRef}`);\n }\n\n /** Back to the original branch; any halted merge, the throwaway and the state file are gone. */\n private async restore(repoRoot: string, state: PushDevState): Promise<void> {\n // Only ever on the throwaway: a reset anywhere else could destroy somebody's uncommitted work.\n // Both allowed to fail: there is no merge to abort once it completed, and nothing to reset on a\n // clean tree. Neither is an error — the rest of the teardown must still run.\n if (await this.gitExec.currentBranch(repoRoot) === state.tmpBranch) {\n await this.gitExec.tryGit(['-C', repoRoot, 'merge', '--abort'], repoRoot);\n await this.gitExec.tryGit(['-C', repoRoot, 'reset', '--hard', 'HEAD'], repoRoot);\n }\n await this.gitExec.runGitChecked(['-C', repoRoot, 'checkout', state.originalBranch],\n `Failed to return to ${state.originalBranch}`);\n await this.gitExec.tryGit(['-C', repoRoot, 'branch', '-D', state.tmpBranch], repoRoot);\n this.store.clear(repoRoot);\n }\n\n private verifiedBanner(state: PushDevState, devSha: string): string {\n const what = state.resolvedPaths.length === 0\n ? 'your branch exactly as it is'\n : `your branch plus ONE commit recording the resolution of ${String(state.resolvedPaths.length)} file(s) — no merge, so no other copy becomes part of its history`;\n return '\\n' + SEP + `✅ ${state.targetRef} is verified against origin/${state.devBranch}\\n` + SEP + '\\n'\n + `It merges with origin/${state.devBranch} (${devSha.slice(0, 8)}), pnpm install ran on the merged tree, and the dev\\n`\n + `build is green. The copy to publish is ${what}.\\n`\n + `You are back on \\`${state.originalBranch}\\`, which this check never modified.\\n\\n`\n + `▶ NEXT run: ${WP_FINISH_PUSH_DEV}\\n`\n + ` It publishes the verified copy as \\`${state.targetRef}\\`. It refuses if \\`${state.originalBranch}\\`\\n`\n + ' moves before then — a new commit means a new check.\\n';\n }\n\n /** Conflicted (unmerged-in-index) paths. Empty once every one has been resolved and `git add`ed. */\n private async unmergedPaths(repoRoot: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['-C', repoRoot, 'diff', '--name-only', '--diff-filter=U'], repoRoot,\n 'Failed to list the conflicted files (git diff --name-only --diff-filter=U).');\n return out.split('\\n').filter((l: string): boolean => l.trim() !== '');\n }\n\n // The gate on resuming: refuse (and re-print the list) while anything is still unmerged.\n private async assertNoUnmergedPaths(repoRoot: string): Promise<void> {\n const conflicted = await this.unmergedPaths(repoRoot);\n if (conflicted.length === 0) return;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ Conflicts are NOT resolved yet\\n' + SEP + '\\n'\n + `${WP_BUILD_PUSH_DEV} commits the resolution — it cannot write one for you. These files are still\\n`\n + 'unmerged (edit until no conflict markers remain, then `git add` each one):\\n'\n + conflicted.map((f: string): string => ` ${f}`).join('\\n') + '\\n\\n'\n + `Give up instead with: ${WP_BUILD_PUSH_DEV} --abort\\n`);\n }\n\n /**\n * The name of the throwaway branch for a check of `branch`.\n *\n * Suffixed rather than prefixed, matching the existing `<feature>Squash` / `<feature>PreMerge<n>`\n * convention — and deliberately NOT inside the dev namespace, which holds REMOTE copies only.\n */\n tmpBranchFor(branch: string): string {\n return `${branch}DevResolve`;\n }\n\n /** The banner `wp-build-push-dev` prints before its check against dev. */\n announce(cfg: DevDeployConfig, state: PushDevState): string {\n return '\\n' + SEP + `🔎 Checking ${state.targetRef} against origin/${cfg.devBranch}\\n` + SEP + '\\n'\n + `Merging origin/${cfg.devBranch} into the throwaway branch \\`${state.tmpBranch}\\`, then running \\`pnpm install\\`\\n`\n + 'and `commands.push-dev.buildCommand` (compile + tests only — the code rules already judged your branch\\n'\n + 'against main, and must never judge the other copies on dev) on the merged tree. A conflict whose dev\\n'\n + 'side comes only from copies already on origin/main takes your side automatically.\\n'\n + `Nothing is published here — when both pass, ${WP_FINISH_PUSH_DEV} publishes your branch, plus ONE\\n`\n + 'commit holding any resolved files. The merge itself is never published.\\n'\n + `Your feature branch \\`${state.originalBranch}\\` is not touched by any of this.\\n\\n`;\n }\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DevDeployConfig } from '@webpieces/rules-config';
|
|
2
|
+
import { GitExec } from './git-exec';
|
|
3
|
+
import { DevDeployRefs } from './dev-deploy-refs';
|
|
4
|
+
import { DevCopyOnMain } from './dev-copy-on-main';
|
|
5
|
+
/**
|
|
6
|
+
* One conflicted file resolved automatically, and the landed copies whose old version of it was
|
|
7
|
+
* overridden. Data-only per CLAUDE.md.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LandedOverride {
|
|
10
|
+
readonly file: string;
|
|
11
|
+
/** The copy refs (`dev-include/<branch>`) whose dev-side version of `file` was overridden. */
|
|
12
|
+
readonly copies: string[];
|
|
13
|
+
constructor(file: string,
|
|
14
|
+
/** The copy refs (`dev-include/<branch>`) whose dev-side version of `file` was overridden. */
|
|
15
|
+
copies: string[]);
|
|
16
|
+
}
|
|
17
|
+
/** What {@link LandedCopyResolver.resolve} did: what it took the publisher's side on, and what is left. Data-only. */
|
|
18
|
+
export declare class LandedResolution {
|
|
19
|
+
readonly overridden: LandedOverride[];
|
|
20
|
+
/** The conflicted files nothing could prove safe to resolve automatically — the developer's job. */
|
|
21
|
+
readonly remaining: string[];
|
|
22
|
+
constructor(overridden: LandedOverride[],
|
|
23
|
+
/** The conflicted files nothing could prove safe to resolve automatically — the developer's job. */
|
|
24
|
+
remaining: string[]);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the conflicts of `wp-build-push-dev`'s dev merge that are caused ONLY by copies already on main
|
|
28
|
+
* (#1405), by taking the publisher's side.
|
|
29
|
+
*
|
|
30
|
+
* THE SHAPE IT CURES: a copy is published to dev, then its branch lands on main with DIFFERENT content
|
|
31
|
+
* (review commits, then a squash). `dev` still holds the published version of those lines, every branch cut
|
|
32
|
+
* from the latest main carries the landed version, and so every new publish conflicts in the same files —
|
|
33
|
+
* the landed copy's old version against its own final version, with nobody's own change involved.
|
|
34
|
+
*
|
|
35
|
+
* WHY THE PUBLISHER'S SIDE IS RIGHT: the publisher's branch contains the latest `origin/main` (stage ②
|
|
36
|
+
* refuses one that does not), so it already carries the landed copy's FINAL version of the file. Taking it
|
|
37
|
+
* loses nothing, and the copy's content is unchanged, so nothing is redeployed. Dropping landed copies when
|
|
38
|
+
* dev is composed would also cure it, but that is a recompose — a full redeploy (#1401).
|
|
39
|
+
*
|
|
40
|
+
* WHEN IT ACTS, per conflicted file: every live copy that changes the file (relative to its merge-base with
|
|
41
|
+
* `origin/main`) is superseded by main — its branch has a merged PR, or main already holds the copy's content
|
|
42
|
+
* of that file. One copy that is NOT on main, or no copy at all explaining the dev side, and the file is left
|
|
43
|
+
* for the developer, exactly as before: that conflict is somebody's live work.
|
|
44
|
+
*/
|
|
45
|
+
export declare class LandedCopyResolver {
|
|
46
|
+
private readonly gitExec;
|
|
47
|
+
private readonly refs;
|
|
48
|
+
private readonly onMain;
|
|
49
|
+
constructor(gitExec: GitExec, refs: DevDeployRefs, onMain: DevCopyOnMain);
|
|
50
|
+
/** Resolve what it can (taking HEAD's side, then `git add`), and return what it did and what remains. */
|
|
51
|
+
resolve(repoRoot: string, cfg: DevDeployConfig, conflicted: string[]): Promise<LandedResolution>;
|
|
52
|
+
/** The report line block for what was overridden; '' when nothing was. */
|
|
53
|
+
describe(resolution: LandedResolution): string;
|
|
54
|
+
private copiesTouching;
|
|
55
|
+
private takePublishersSide;
|
|
56
|
+
}
|