@webpieces/pr-gate 0.4.982 → 0.4.984
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 +7 -6
- package/src/scripts/commands/build-dev-command.d.ts +27 -0
- package/src/scripts/commands/build-dev-command.js +99 -0
- package/src/scripts/commands/build-dev-command.js.map +1 -0
- package/src/scripts/commands/push-dev-command.d.ts +49 -19
- package/src/scripts/commands/push-dev-command.js +95 -32
- package/src/scripts/commands/push-dev-command.js.map +1 -1
- package/src/scripts/pr-gate-app.d.ts +10 -2
- package/src/scripts/pr-gate-app.js +15 -2
- package/src/scripts/pr-gate-app.js.map +1 -1
- package/src/scripts/pr-gate-cli-app.d.ts +1 -0
- package/src/scripts/pr-gate-cli-app.js +9 -2
- package/src/scripts/pr-gate-cli-app.js.map +1 -1
- package/src/scripts/workflow/build-affected.d.ts +7 -0
- package/src/scripts/workflow/build-affected.js +12 -4
- package/src/scripts/workflow/build-affected.js.map +1 -1
- package/src/scripts/workflow/build-gate-log.d.ts +4 -2
- package/src/scripts/workflow/build-gate-log.js +11 -3
- package/src/scripts/workflow/build-gate-log.js.map +1 -1
- package/src/scripts/workflow/dev-build.d.ts +31 -0
- package/src/scripts/workflow/dev-build.js +63 -0
- package/src/scripts/workflow/dev-build.js.map +1 -0
- package/src/scripts/workflow/dev-copy-on-main.d.ts +49 -0
- package/src/scripts/workflow/dev-copy-on-main.js +99 -0
- package/src/scripts/workflow/dev-copy-on-main.js.map +1 -0
- package/src/scripts/workflow/dev-deploy-refs.d.ts +13 -2
- package/src/scripts/workflow/dev-deploy-refs.js +17 -5
- package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
- package/src/scripts/workflow/dev-resolve-runner.d.ts +55 -8
- package/src/scripts/workflow/dev-resolve-runner.js +150 -22
- package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
- package/src/scripts/workflow/push-dev-state.d.ts +27 -0
- package/src/scripts/workflow/push-dev-state.js +41 -3
- package/src/scripts/workflow/push-dev-state.js.map +1 -1
- package/src/scripts/wp-build-dev.d.ts +2 -0
- package/src/scripts/wp-build-dev.js +13 -0
- package/src/scripts/wp-build-dev.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-deploy-refs.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-deploy-refs.ts"],"names":[],"mappings":";;;;AAAA,0DAAsG;AACtG,yCAA2D;AAC3D,8DAAwD;AAExD,yCAAqC;AAErC,MAAM,GAAG,GAAG,0DAA0D,CAAC;AACvE,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAa,OAAO;IAChB,iFAAiF;IACjF,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,uFAAuF;IACvF,YAAY,CAAS;IAErB,YAAY,GAAW,EAAE,GAAW,EAAE,YAAoB;QACtD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AAZD,0BAYC;AAED;;;;;;;;;;GAUG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAa;IACO;IAA7B,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAEjD,4GAA4G;IAC5G,MAAM,CAAC,QAAgB;QACnB,OAAO,IAAA,8BAAe,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;IACtD,CAAC;IAED,0GAA0G;IAC1G,aAAa,CAAC,QAAgB;QAC1B,OAAO,4BAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;OAUG;IACH,cAAc,CAAC,GAAoB,EAAE,MAAc;QAC/C,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,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M,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,EAC1E,+CAA+C,CAAC,CAAC;IACzD,CAAC;IAED,0GAA0G;IAC1G,KAAK,CAAC,mBAAmB,CAAC,QAAgB,EAAE,GAAW;QACnD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,6BAA6B,GAAG,EAAE,CAAC,EAAE,QAAQ,EACzG,yCAAyC,GAAG,0BAA0B,CAAC,CAAC;QAC5E,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAEO,OAAO,CAAC,QAAgB,EAAE,IAAY;QAC1C,OAAO,IAAI,GAAG,GAAG,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,WAAW,0BAAW,mCAAmC,CAAC;IAC1H,CAAC;CACJ,CAAA;AAxIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEC,kBAAO;GADpC,aAAa,CAwIzB","sourcesContent":["import { CliExitError, DevDeployConfig, loadAndValidate, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { gitCheckout } from '@webpieces/tooling-common';\n\nimport { GitExec } from './git-exec';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\nconst MAIN = 'main';\nconst DETACHED = 'HEAD';\n\n/**\n * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —\n * `--list` prints it and the clobber guard compares against `sha`, and neither should be re-parsing\n * `ls-remote` output.\n */\nexport class DevCopy {\n /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */\n ref: string;\n sha: string;\n /** The feature branch this is a copy OF — `ref` with the namespace prefix stripped. */\n sourceBranch: string;\n\n constructor(ref: string, sha: string, sourceBranch: string) {\n this.ref = ref;\n this.sha = sha;\n this.sourceBranch = sourceBranch;\n }\n}\n\n/**\n * Ref derivation and preconditions for the dev-deploy flow — the half of `wp-push-dev` that decides WHICH\n * refs are in play, kept out of the commands so both `wp-push-dev` and `wp-finish-push-dev` answer those\n * questions identically.\n *\n * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire\n * another developer's commits — landing that PR would ship their unreviewed work to production. Every\n * write this flow performs therefore targets either the `<namespace>/<feature>` copy or a local throwaway\n * branch, and NOTHING here ever moves `<feature>` itself. That is why a conflict resolution needs the copy\n * to live in: it is the only place the resolution can be recorded without contaminating the PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevDeployRefs {\n constructor(private readonly gitExec: GitExec) {}\n\n /** The `pr-gate.devDeploy` block — `dev-include` / `dev` / `dev-remove` unless the consumer overrode it. */\n config(repoRoot: string): DevDeployConfig {\n return loadAndValidate(repoRoot).prGate.devDeploy;\n }\n\n /** The checked-out branch name, or `'HEAD'` on a detached HEAD (which {@link assertPushable} refuses). */\n currentBranch(repoRoot: string): string {\n return gitCheckout.requireBranch(repoRoot);\n }\n\n /**\n * Refuse every branch that must never be the SOURCE of a dev copy, before anything is fetched or\n * pushed.\n *\n * `main` and the composed dev branch are refused for the same reason from opposite ends: `main` is the\n * trunk (whatever is on it already deploys, so copying it is meaningless), and the dev branch is a\n * BUILD ARTIFACT that CI recomputes from `origin/main` on every run — copying it would publish a\n * composition of everyone's work under one developer's name, and it would be wiped on the next CI run\n * anyway. A branch already inside the namespace is refused because publishing a copy of a copy nests\n * the prefix (`dev-include/dev-include/…`) and nothing would ever clean it up.\n */\n assertPushable(cfg: DevDeployConfig, branch: string): void {\n if (branch === DETACHED || branch === '') {\n throw new CliExitError(2, this.refusal(\n 'Detached HEAD',\n 'There is no branch name to derive the dev copy from. Check out your feature branch first:\\n'\n + ' git checkout <your-feature-branch>\\n'));\n }\n if (branch === MAIN) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${MAIN}\\``,\n `\\`${MAIN}\\` is the trunk — whatever is on it already deploys, so a dev copy of it means nothing.\\n`\n + 'Check out the feature branch you actually want on the dev server and re-run.\\n'));\n }\n if (branch === cfg.devBranch) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${cfg.devBranch}\\``,\n `\\`${cfg.devBranch}\\` is a BUILD ARTIFACT, not a source branch: your CI resets it to origin/${MAIN},\\n`\n + `merges every \\`${cfg.copyRefGlob()}\\` ref into it, and force-pushes — every run. Copying it would\\n`\n + \"publish a composition of everybody's work under your branch's name, and the next CI run would\\n\"\n + 'wipe it. Check out your own feature branch and re-run.\\n'));\n }\n if (branch === cfg.branchNamespace || branch.startsWith(`${cfg.branchNamespace}/`)) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of a dev copy (\\`${branch}\\`)`,\n `\\`${cfg.branchNamespace}/\\` holds the disposable copies this command WRITES; you are standing on one.\\n`\n + `Publishing from here would nest the prefix (\\`${cfg.branchNamespace}/${branch}\\`) and nothing ever\\n`\n + 'cleans that up. Check out the real feature branch and re-run.\\n'));\n }\n }\n\n /**\n * Every live copy in the namespace, sorted by ref name.\n *\n * The sort is not cosmetic: `--resolve` with no argument queues these in exactly this order, and the\n * consumer's CI composes `dev` in the same order, so what a developer resolves locally is the\n * composition CI will actually build. A different order can produce a different (still valid) merge\n * result, which would make the local resolution a guess about CI rather than a rehearsal of it.\n */\n async liveCopies(repoRoot: string, cfg: DevDeployConfig): Promise<DevCopy[]> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', cfg.copyRefGlob()], repoRoot,\n `Failed to list the dev copies (git ls-remote --heads origin '${cfg.copyRefGlob()}').`);\n const copies: DevCopy[] = [];\n for (const line of out.split('\\n')) {\n if (line.trim() === '') continue;\n const fields = line.split(/\\s+/);\n const sha = fields[0];\n const ref = fields[1];\n if (sha === undefined || ref === undefined || !ref.startsWith('refs/heads/')) continue;\n const shortRef = ref.slice('refs/heads/'.length);\n copies.push(new DevCopy(shortRef, sha, shortRef.slice(cfg.branchNamespace.length + 1)));\n }\n return copies.sort((a: DevCopy, b: DevCopy): number => (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0));\n }\n\n /**\n * The sha of a local ref (default HEAD).\n *\n * Read AFTER a push so the watch hints quote the sha that is provably published. Quoting the copy\n * REF instead would be a moving target — it advances the next time anybody publishes — and the whole\n * value of the \"did my code land in dev\" check is that it is a claim about one specific commit.\n */\n headSha(repoRoot: string, ref = 'HEAD'): Promise<string> {\n return this.gitExec.gitQuery(['-C', repoRoot, 'rev-parse', ref], repoRoot,\n `Failed to read the sha of ${ref} (git rev-parse).`);\n }\n\n /**\n * Fetch `origin/main` and return its sha — what the `--remove` marker points at (#1395).\n *\n * The marker carries no content, so any sha the remote already has would do; `main`'s tip is chosen\n * because it is guaranteed to exist on origin (the push sends no objects) and it is what the\n * consumer's workflow composes from anyway. Fetched rather than read from the local tracking ref, so a\n * clone that has not fetched in weeks does not point the marker at an arbitrarily old commit.\n */\n async freshMainTip(repoRoot: string): Promise<string> {\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', `+refs/heads/${MAIN}:refs/remotes/origin/${MAIN}`],\n `Failed to fetch origin/${MAIN}, which the --remove marker points at. Nothing was removed`);\n return this.headSha(repoRoot, `refs/remotes/origin/${MAIN}`);\n }\n\n /** The remote sha of one copy, or '' when that copy does not exist yet. */\n async remoteSha(repoRoot: string, ref: string): Promise<string> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', ref], repoRoot,\n `Failed to look up origin/${ref} (git ls-remote).`);\n const line = out.split('\\n').find((l: string): boolean => l.trim() !== '');\n if (line === undefined) return '';\n return line.split(/\\s+/)[0] ?? '';\n }\n\n /**\n * Fetch the named copy refs into `refs/remotes/origin/<ref>` so the local merges below run against\n * fresh state. A no-op for an empty list, and a hard failure otherwise: a resolve queued against\n * stale refs rehearses a composition CI will not build.\n */\n async fetchCopies(repoRoot: string, refs: string[]): Promise<void> {\n if (refs.length === 0) return;\n const specs = refs.map((r: string): string => `+refs/heads/${r}:refs/remotes/origin/${r}`);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', ...specs],\n 'Failed to fetch the dev copy refs from origin');\n }\n\n /** How many commits `origin/<ref>` has that `HEAD` does not — the clobber signal. 0 = safe to publish. */\n async commitsOnlyOnRemote(repoRoot: string, ref: string): Promise<number> {\n const out = await this.gitExec.gitQuery(['rev-list', '--count', `HEAD..refs/remotes/origin/${ref}`], repoRoot,\n `Failed to compare HEAD against origin/${ref} (git rev-list --count).`);\n const count = Number(out);\n return Number.isInteger(count) ? count : 0;\n }\n\n private refusal(headline: string, body: string): string {\n return '\\n' + SEP + `⛔ ${headline}\\n` + SEP + '\\n' + body + `\\nRun \\`${WP_PUSH_DEV} --help\\` for the full command.\\n`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dev-deploy-refs.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-deploy-refs.ts"],"names":[],"mappings":";;;;AAAA,0DAAsG;AACtG,yCAA2D;AAC3D,8DAAwD;AAExD,yCAAqC;AAErC,MAAM,GAAG,GAAG,0DAA0D,CAAC;AACvE,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAa,OAAO;IAChB,iFAAiF;IACjF,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,uFAAuF;IACvF,YAAY,CAAS;IAErB,YAAY,GAAW,EAAE,GAAW,EAAE,YAAoB;QACtD,IAAI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AC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;IAEO,OAAO,CAAC,QAAgB,EAAE,IAAY;QAC1C,OAAO,IAAI,GAAG,GAAG,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,WAAW,0BAAW,mCAAmC,CAAC;IAC1H,CAAC;CACJ,CAAA;AArJY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEC,kBAAO;GADpC,aAAa,CAqJzB","sourcesContent":["import { CliExitError, DevDeployConfig, loadAndValidate, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { gitCheckout } from '@webpieces/tooling-common';\n\nimport { GitExec } from './git-exec';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\nconst MAIN = 'main';\nconst DETACHED = 'HEAD';\n\n/**\n * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —\n * `--list` prints it and the clobber guard compares against `sha`, and neither should be re-parsing\n * `ls-remote` output.\n */\nexport class DevCopy {\n /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */\n ref: string;\n sha: string;\n /** The feature branch this is a copy OF — `ref` with the namespace prefix stripped. */\n sourceBranch: string;\n\n constructor(ref: string, sha: string, sourceBranch: string) {\n this.ref = ref;\n this.sha = sha;\n this.sourceBranch = sourceBranch;\n }\n}\n\n/**\n * Ref derivation and preconditions for the dev-deploy flow — the half of `wp-push-dev` that decides WHICH\n * refs are in play, kept out of the commands so both `wp-push-dev` and `wp-finish-push-dev` answer those\n * questions identically.\n *\n * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire\n * another developer's commits — landing that PR would ship their unreviewed work to production. Every\n * write this flow performs therefore targets either the `<namespace>/<feature>` copy or a local throwaway\n * branch, and NOTHING here ever moves `<feature>` itself. That is why a conflict resolution needs the copy\n * to live in: it is the only place the resolution can be recorded without contaminating the PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevDeployRefs {\n constructor(private readonly gitExec: GitExec) {}\n\n /** The `pr-gate.devDeploy` block — `dev-include` / `dev` / `dev-remove` unless the consumer overrode it. */\n config(repoRoot: string): DevDeployConfig {\n return loadAndValidate(repoRoot).prGate.devDeploy;\n }\n\n /**\n * `commands.push-dev.buildCommand`, or `undefined` when the consumer has not configured it. There is\n * no default (#1397, `.claude/rules/no-rule-defaults.md`); DevBuild turns `undefined` into the refusal\n * that names the key.\n */\n devBuildCommand(repoRoot: string): string | undefined {\n return loadAndValidate(repoRoot).commands.pushDev.buildCommand;\n }\n\n /** The checked-out branch name, or `'HEAD'` on a detached HEAD (which {@link assertPushable} refuses). */\n currentBranch(repoRoot: string): string {\n return gitCheckout.requireBranch(repoRoot);\n }\n\n /**\n * Refuse every branch that must never be the SOURCE of a dev copy, before anything is fetched or\n * pushed.\n *\n * `main` and the composed dev branch are refused for the same reason from opposite ends: `main` is the\n * trunk (whatever is on it already deploys, so copying it is meaningless), and the dev branch is a\n * BUILD ARTIFACT that CI recomputes from `origin/main` on every run — copying it would publish a\n * composition of everyone's work under one developer's name, and it would be wiped on the next CI run\n * anyway. A branch already inside the namespace is refused because publishing a copy of a copy nests\n * the prefix (`dev-include/dev-include/…`) and nothing would ever clean it up.\n */\n assertPushable(cfg: DevDeployConfig, branch: string): void {\n if (branch === DETACHED || branch === '') {\n throw new CliExitError(2, this.refusal(\n 'Detached HEAD',\n 'There is no branch name to derive the dev copy from. Check out your feature branch first:\\n'\n + ' git checkout <your-feature-branch>\\n'));\n }\n if (branch === MAIN) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${MAIN}\\``,\n `\\`${MAIN}\\` is the trunk — whatever is on it already deploys, so a dev copy of it means nothing.\\n`\n + 'Check out the feature branch you actually want on the dev server and re-run.\\n'));\n }\n if (branch === cfg.devBranch) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${cfg.devBranch}\\``,\n `\\`${cfg.devBranch}\\` is a BUILD ARTIFACT, not a source branch: your CI resets it to origin/${MAIN},\\n`\n + `merges every \\`${cfg.copyRefGlob()}\\` ref into it, and force-pushes — every run. Copying it would\\n`\n + \"publish a composition of everybody's work under your branch's name, and the next CI run would\\n\"\n + 'wipe it. Check out your own feature branch and re-run.\\n'));\n }\n if (branch === cfg.branchNamespace || branch.startsWith(`${cfg.branchNamespace}/`)) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of a dev copy (\\`${branch}\\`)`,\n `\\`${cfg.branchNamespace}/\\` holds the disposable copies this command WRITES; you are standing on one.\\n`\n + `Publishing from here would nest the prefix (\\`${cfg.branchNamespace}/${branch}\\`) and nothing ever\\n`\n + 'cleans that up. Check out the real feature branch and re-run.\\n'));\n }\n }\n\n /**\n * Every live copy in the namespace, sorted by ref name.\n *\n * The sort is not cosmetic: `--resolve` with no argument queues these in exactly this order, and the\n * consumer's CI composes `dev` in the same order, so what a developer resolves locally is the\n * composition CI will actually build. A different order can produce a different (still valid) merge\n * result, which would make the local resolution a guess about CI rather than a rehearsal of it.\n */\n async liveCopies(repoRoot: string, cfg: DevDeployConfig): Promise<DevCopy[]> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', cfg.copyRefGlob()], repoRoot,\n `Failed to list the dev copies (git ls-remote --heads origin '${cfg.copyRefGlob()}').`);\n const copies: DevCopy[] = [];\n for (const line of out.split('\\n')) {\n if (line.trim() === '') continue;\n const fields = line.split(/\\s+/);\n const sha = fields[0];\n const ref = fields[1];\n if (sha === undefined || ref === undefined || !ref.startsWith('refs/heads/')) continue;\n const shortRef = ref.slice('refs/heads/'.length);\n copies.push(new DevCopy(shortRef, sha, shortRef.slice(cfg.branchNamespace.length + 1)));\n }\n return copies.sort((a: DevCopy, b: DevCopy): number => (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0));\n }\n\n /**\n * The sha of a local ref (default HEAD).\n *\n * Read AFTER a push so the watch hints quote the sha that is provably published. Quoting the copy\n * REF instead would be a moving target — it advances the next time anybody publishes — and the whole\n * value of the \"did my code land in dev\" check is that it is a claim about one specific commit.\n */\n headSha(repoRoot: string, ref = 'HEAD'): Promise<string> {\n return this.gitExec.gitQuery(['-C', repoRoot, 'rev-parse', ref], repoRoot,\n `Failed to read the sha of ${ref} (git rev-parse).`);\n }\n\n /**\n * Fetch `origin/main` and return its sha — what the `--remove` marker points at (#1395).\n *\n * The marker carries no content, so any sha the remote already has would do; `main`'s tip is chosen\n * because it is guaranteed to exist on origin (the push sends no objects) and it is what the\n * consumer's workflow composes from anyway. Fetched rather than read from the local tracking ref, so a\n * clone that has not fetched in weeks does not point the marker at an arbitrarily old commit.\n */\n async freshMainTip(repoRoot: string): Promise<string> {\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', `+refs/heads/${MAIN}:refs/remotes/origin/${MAIN}`],\n `Failed to fetch origin/${MAIN}, which the --remove marker points at. Nothing was removed`);\n return this.headSha(repoRoot, `refs/remotes/origin/${MAIN}`);\n }\n\n /** The remote sha of one copy, or '' when that copy does not exist yet. */\n async remoteSha(repoRoot: string, ref: string): Promise<string> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', ref], repoRoot,\n `Failed to look up origin/${ref} (git ls-remote).`);\n const line = out.split('\\n').find((l: string): boolean => l.trim() !== '');\n if (line === undefined) return '';\n return line.split(/\\s+/)[0] ?? '';\n }\n\n /**\n * Fetch the named copy refs into `refs/remotes/origin/<ref>` so the local merges below run against\n * fresh state. A no-op for an empty list, and a hard failure otherwise: a resolve queued against\n * stale refs rehearses a composition CI will not build.\n */\n async fetchCopies(repoRoot: string, refs: string[]): Promise<void> {\n if (refs.length === 0) return;\n const specs = refs.map((r: string): string => `+refs/heads/${r}:refs/remotes/origin/${r}`);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', ...specs],\n 'Failed to fetch the dev copy refs from origin');\n }\n\n /**\n * The subject of every commit `origin/<ref>` has that `HEAD` does not — the clobber signal. Empty =\n * safe to publish. Subjects rather than a count, because a commit this flow wrote itself (a recorded\n * conflict resolution, see DevResolveRunner) is re-derived by the next publish's check against dev and\n * is therefore safe to replace, while anything else on the copy is somebody's work.\n */\n async subjectsOnlyOnRemote(repoRoot: string, ref: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['log', '--format=%s', `HEAD..refs/remotes/origin/${ref}`], repoRoot,\n `Failed to compare HEAD against origin/${ref} (git log HEAD..origin/${ref}).`);\n return out.split('\\n').filter((l: string): boolean => l.trim() !== '');\n }\n\n private refusal(headline: string, body: string): string {\n return '\\n' + SEP + `⛔ ${headline}\\n` + SEP + '\\n' + body + `\\nRun \\`${WP_PUSH_DEV} --help\\` for the full command.\\n`;\n }\n}\n"]}
|
|
@@ -3,8 +3,16 @@ import { GitExec } from './git-exec';
|
|
|
3
3
|
import { DevDeployRefs } from './dev-deploy-refs';
|
|
4
4
|
import { PushDevState, PushDevStateStore } from './push-dev-state';
|
|
5
5
|
import { DevDeployWatchHints } from './dev-deploy-watch-hints';
|
|
6
|
+
import { DevBuild } from './dev-build';
|
|
6
7
|
/**
|
|
7
|
-
* The
|
|
8
|
+
* The subject prefix of the ONE commit this flow writes onto a copy: the recorded conflict resolution.
|
|
9
|
+
* The clobber guard reads it — a remote-only commit with this subject is re-derived by the next publish's
|
|
10
|
+
* check against dev, so replacing it destroys nothing; any other remote-only commit is somebody's work.
|
|
11
|
+
*/
|
|
12
|
+
export declare const RESOLUTION_SUBJECT = "Dev-deploy: conflict resolution for";
|
|
13
|
+
/**
|
|
14
|
+
* The queue-draining engine behind `wp-push-dev` (its pre-publish check against dev, #1397),
|
|
15
|
+
* `wp-push-dev --resolve`, `--rebase-resolution`, and `wp-finish-push-dev`.
|
|
8
16
|
*
|
|
9
17
|
* ONE class owns every git WRITE in the resolve flow, and that is a hard requirement rather than tidiness:
|
|
10
18
|
* `redirect-how-to-merge-main` blocks `git merge` in every form INCLUDING `--continue`, and
|
|
@@ -18,7 +26,8 @@ export declare class DevResolveRunner {
|
|
|
18
26
|
private readonly refs;
|
|
19
27
|
private readonly store;
|
|
20
28
|
private readonly watchHints;
|
|
21
|
-
|
|
29
|
+
private readonly devBuild;
|
|
30
|
+
constructor(gitExec: GitExec, refs: DevDeployRefs, store: PushDevStateStore, watchHints: DevDeployWatchHints, devBuild: DevBuild);
|
|
22
31
|
/**
|
|
23
32
|
* Start a resolve: park on a throwaway branch at the current copy, then drain the queue.
|
|
24
33
|
*
|
|
@@ -26,10 +35,12 @@ export declare class DevResolveRunner {
|
|
|
26
35
|
* mechanical — every merge below lands on a branch that is deleted at the end, so no other developer's
|
|
27
36
|
* commits can reach the PR head even if the resolve is abandoned halfway.
|
|
28
37
|
*
|
|
29
|
-
* `base` differs between the
|
|
30
|
-
*
|
|
31
|
-
* starts at the
|
|
32
|
-
* the
|
|
38
|
+
* `base` differs between the callers and the difference IS the semantics. A plain publish starts at the
|
|
39
|
+
* LOCAL HEAD and merges `origin/<devBranch>` in (does this copy merge and build against what is already
|
|
40
|
+
* on dev?). `--resolve` starts at the published copy and merges the other copies in (compose what CI
|
|
41
|
+
* will build). `--rebase-resolution` starts at the LOCAL HEAD and merges the published copy in (replay
|
|
42
|
+
* an existing resolution on top of the new commits, instead of force-pushing over it). What is finally
|
|
43
|
+
* PUBLISHED is the state's DevResolveMode's decision — see finalize.
|
|
33
44
|
*
|
|
34
45
|
* `fetchRefs` is passed separately from the queue because `--rebase-resolution` merges a ref that is
|
|
35
46
|
* also its push destination, so "everything to fetch" and "everything to merge" are not the same list.
|
|
@@ -57,8 +68,42 @@ export declare class DevResolveRunner {
|
|
|
57
68
|
private drain;
|
|
58
69
|
/** Stop with the conflicted files listed and the ONE command that continues. Exit 2 = "your turn". */
|
|
59
70
|
private halt;
|
|
60
|
-
/**
|
|
61
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Queue empty. What happens next is the mode's (see DevResolveMode):
|
|
73
|
+
*
|
|
74
|
+
* - PREBUILD runs the dev build on the MERGED tree first, so a red build stops before anything is
|
|
75
|
+
* published.
|
|
76
|
+
* - PREBUILD and COMPOSE then publish the BASE plus the recorded resolution — never the merge. REPLAY
|
|
77
|
+
* publishes the merge, as it always has.
|
|
78
|
+
*/
|
|
79
|
+
private finalize;
|
|
80
|
+
/**
|
|
81
|
+
* Run the dev build on the merged throwaway. On a red build, put the checkout back first — the fix
|
|
82
|
+
* belongs on the feature branch, and a developer left parked on a throwaway would make the next
|
|
83
|
+
* `wp-*` command act on the wrong branch — then let the build's own failure (with its `FullLog :`
|
|
84
|
+
* pointer) reach the top-level handler unchanged.
|
|
85
|
+
*/
|
|
86
|
+
private buildOrRestore;
|
|
87
|
+
/**
|
|
88
|
+
* Turn the throwaway into what gets PUBLISHED: the base sha plus, when anything conflicted, ONE commit
|
|
89
|
+
* that sets each resolved file to its resolved content.
|
|
90
|
+
*
|
|
91
|
+
* This is issue #1397's option (a): the merge is used for the conflict check and the build only, and
|
|
92
|
+
* is never published. Publishing it would make every other copy an ancestor of this one, so a later
|
|
93
|
+
* `--remove` of that copy would leave its commits on dev through ours. The resolution commit has
|
|
94
|
+
* exactly one parent, the base, so the only thing it can carry of anybody else's work is the text of
|
|
95
|
+
* the hunks that were resolved — content, never history.
|
|
96
|
+
*/
|
|
97
|
+
private recordResolution;
|
|
98
|
+
/** Back to the original branch; the throwaway and the state file are gone. */
|
|
99
|
+
private restore;
|
|
100
|
+
/**
|
|
101
|
+
* PREBUILD leases against the sha the clobber guard inspected (plain `--force` only when asked); the
|
|
102
|
+
* other two modes overwrite the copy they themselves started from, as they always have.
|
|
103
|
+
*/
|
|
104
|
+
private pushSafety;
|
|
105
|
+
private buildStep;
|
|
106
|
+
private publishedBanner;
|
|
62
107
|
/** Conflicted (unmerged-in-index) paths. Empty once every one has been resolved and `git add`ed. */
|
|
63
108
|
private unmergedPaths;
|
|
64
109
|
private assertNoUnmergedPaths;
|
|
@@ -71,4 +116,6 @@ export declare class DevResolveRunner {
|
|
|
71
116
|
tmpBranchFor(branch: string): string;
|
|
72
117
|
/** The banner `--resolve` prints before the first merge, so the queue is visible before it halts. */
|
|
73
118
|
announce(cfg: DevDeployConfig, state: PushDevState): string;
|
|
119
|
+
/** The banner plain `wp-push-dev` prints before its check against dev (#1397). */
|
|
120
|
+
announcePrebuild(cfg: DevDeployConfig, state: PushDevState): string;
|
|
74
121
|
}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DevResolveRunner = void 0;
|
|
3
|
+
exports.DevResolveRunner = exports.RESOLUTION_SUBJECT = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
6
|
+
const to_error_1 = require("@webpieces/tooling-common/to-error");
|
|
6
7
|
const inversify_1 = require("inversify");
|
|
7
8
|
const git_exec_1 = require("./git-exec");
|
|
8
9
|
const dev_deploy_refs_1 = require("./dev-deploy-refs");
|
|
9
10
|
const push_dev_state_1 = require("./push-dev-state");
|
|
10
11
|
const dev_deploy_watch_hints_1 = require("./dev-deploy-watch-hints");
|
|
12
|
+
const dev_build_1 = require("./dev-build");
|
|
11
13
|
const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
|
|
12
14
|
/**
|
|
13
|
-
* The
|
|
15
|
+
* The subject prefix of the ONE commit this flow writes onto a copy: the recorded conflict resolution.
|
|
16
|
+
* The clobber guard reads it — a remote-only commit with this subject is re-derived by the next publish's
|
|
17
|
+
* check against dev, so replacing it destroys nothing; any other remote-only commit is somebody's work.
|
|
18
|
+
*/
|
|
19
|
+
exports.RESOLUTION_SUBJECT = 'Dev-deploy: conflict resolution for';
|
|
20
|
+
/**
|
|
21
|
+
* The queue-draining engine behind `wp-push-dev` (its pre-publish check against dev, #1397),
|
|
22
|
+
* `wp-push-dev --resolve`, `--rebase-resolution`, and `wp-finish-push-dev`.
|
|
14
23
|
*
|
|
15
24
|
* ONE class owns every git WRITE in the resolve flow, and that is a hard requirement rather than tidiness:
|
|
16
25
|
* `redirect-how-to-merge-main` blocks `git merge` in every form INCLUDING `--continue`, and
|
|
@@ -24,11 +33,13 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
24
33
|
refs;
|
|
25
34
|
store;
|
|
26
35
|
watchHints;
|
|
27
|
-
|
|
36
|
+
devBuild;
|
|
37
|
+
constructor(gitExec, refs, store, watchHints, devBuild) {
|
|
28
38
|
this.gitExec = gitExec;
|
|
29
39
|
this.refs = refs;
|
|
30
40
|
this.store = store;
|
|
31
41
|
this.watchHints = watchHints;
|
|
42
|
+
this.devBuild = devBuild;
|
|
32
43
|
}
|
|
33
44
|
/**
|
|
34
45
|
* Start a resolve: park on a throwaway branch at the current copy, then drain the queue.
|
|
@@ -37,16 +48,21 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
37
48
|
* mechanical — every merge below lands on a branch that is deleted at the end, so no other developer's
|
|
38
49
|
* commits can reach the PR head even if the resolve is abandoned halfway.
|
|
39
50
|
*
|
|
40
|
-
* `base` differs between the
|
|
41
|
-
*
|
|
42
|
-
* starts at the
|
|
43
|
-
* the
|
|
51
|
+
* `base` differs between the callers and the difference IS the semantics. A plain publish starts at the
|
|
52
|
+
* LOCAL HEAD and merges `origin/<devBranch>` in (does this copy merge and build against what is already
|
|
53
|
+
* on dev?). `--resolve` starts at the published copy and merges the other copies in (compose what CI
|
|
54
|
+
* will build). `--rebase-resolution` starts at the LOCAL HEAD and merges the published copy in (replay
|
|
55
|
+
* an existing resolution on top of the new commits, instead of force-pushing over it). What is finally
|
|
56
|
+
* PUBLISHED is the state's DevResolveMode's decision — see finalize.
|
|
44
57
|
*
|
|
45
58
|
* `fetchRefs` is passed separately from the queue because `--rebase-resolution` merges a ref that is
|
|
46
59
|
* also its push destination, so "everything to fetch" and "everything to merge" are not the same list.
|
|
47
60
|
*/
|
|
48
61
|
async start(repoRoot, state, base, fetchRefs) {
|
|
49
62
|
await this.refs.fetchCopies(repoRoot, fetchRefs);
|
|
63
|
+
// Pinned to a SHA after the fetch: the resolution is recorded on top of exactly what was merged,
|
|
64
|
+
// even if the copy (or the feature branch) moves while a conflict is being resolved.
|
|
65
|
+
state.baseSha = await this.refs.headSha(repoRoot, base);
|
|
50
66
|
this.store.write(repoRoot, state);
|
|
51
67
|
await this.gitExec.runGitChecked(['-C', repoRoot, 'checkout', '-B', state.tmpBranch, base], `Failed to create the throwaway resolve branch ${state.tmpBranch}`);
|
|
52
68
|
await this.drain(repoRoot, state);
|
|
@@ -76,9 +92,7 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
76
92
|
// Allowed to fail: there is no merge to abort when the resolve halted between merges, and that is
|
|
77
93
|
// not an error condition — the rest of the teardown must still run.
|
|
78
94
|
await this.gitExec.tryGit(['-C', repoRoot, 'merge', '--abort'], repoRoot);
|
|
79
|
-
await this.
|
|
80
|
-
await this.gitExec.tryGit(['-C', repoRoot, 'branch', '-D', state.tmpBranch], repoRoot);
|
|
81
|
-
this.store.clear(repoRoot);
|
|
95
|
+
await this.restore(repoRoot, state);
|
|
82
96
|
process.stdout.write('\n' + SEP + '🛑 Dev-deploy resolve aborted\n' + SEP + '\n'
|
|
83
97
|
+ `You are back on \`${state.originalBranch}\`; \`${state.tmpBranch}\` and the state file are gone.\n`
|
|
84
98
|
+ `The remote copy \`${state.targetRef}\` is untouched, and so is your feature branch.\n`);
|
|
@@ -100,15 +114,20 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
100
114
|
continue;
|
|
101
115
|
}
|
|
102
116
|
state.current = ref;
|
|
103
|
-
this.store.write(repoRoot, state);
|
|
104
117
|
await this.halt(repoRoot, state);
|
|
105
118
|
return;
|
|
106
119
|
}
|
|
107
|
-
await this.
|
|
120
|
+
await this.finalize(repoRoot, state);
|
|
108
121
|
}
|
|
109
122
|
/** Stop with the conflicted files listed and the ONE command that continues. Exit 2 = "your turn". */
|
|
110
123
|
async halt(repoRoot, state) {
|
|
111
124
|
const conflicted = await this.unmergedPaths(repoRoot);
|
|
125
|
+
// Remembered so the finish records EXACTLY these files as the resolution — and nothing else the
|
|
126
|
+
// merge brought in, which is other developers' work.
|
|
127
|
+
for (const file of conflicted)
|
|
128
|
+
if (!state.resolvedPaths.includes(file))
|
|
129
|
+
state.resolvedPaths.push(file);
|
|
130
|
+
this.store.write(repoRoot, state);
|
|
112
131
|
const remaining = state.queue.length > 0
|
|
113
132
|
? `\nStill queued after this one: ${state.queue.join(', ')}\n`
|
|
114
133
|
+ `\`${rules_config_1.WP_FINISH_PUSH_DEV}\` resumes the queue, so it may stop again on a later ref.\n`
|
|
@@ -120,25 +139,122 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
120
139
|
+ conflicted.map((f) => ` ${f}`).join('\n') + '\n'
|
|
121
140
|
+ remaining
|
|
122
141
|
+ '\nThen run ONE of:\n'
|
|
123
|
-
+ ` ${rules_config_1.WP_FINISH_PUSH_DEV} ← commit, resume the queue, publish the copy\n`
|
|
142
|
+
+ ` ${rules_config_1.WP_FINISH_PUSH_DEV} ← commit, resume the queue, ${this.buildStep(state)}publish the copy\n`
|
|
124
143
|
+ ` ${rules_config_1.WP_FINISH_PUSH_DEV} --abort ← throw it away and go back to \`${state.originalBranch}\`\n\n`
|
|
125
144
|
+ 'Do NOT run `git merge --continue`, `git commit` or `git push` yourself — they are blocked, and\n'
|
|
126
145
|
+ 'the finish command above does all three for you.\n');
|
|
127
146
|
}
|
|
128
|
-
/**
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Queue empty. What happens next is the mode's (see DevResolveMode):
|
|
149
|
+
*
|
|
150
|
+
* - PREBUILD runs the dev build on the MERGED tree first, so a red build stops before anything is
|
|
151
|
+
* published.
|
|
152
|
+
* - PREBUILD and COMPOSE then publish the BASE plus the recorded resolution — never the merge. REPLAY
|
|
153
|
+
* publishes the merge, as it always has.
|
|
154
|
+
*/
|
|
155
|
+
async finalize(repoRoot, state) {
|
|
156
|
+
if (state.mode === push_dev_state_1.DevResolveMode.PREBUILD)
|
|
157
|
+
await this.buildOrRestore(repoRoot, state);
|
|
158
|
+
if (state.mode !== push_dev_state_1.DevResolveMode.REPLAY)
|
|
159
|
+
await this.recordResolution(repoRoot, state);
|
|
160
|
+
// Captured BEFORE the tmp branch is deleted — it is the sha the watch hints are about, and after
|
|
161
|
+
// the restore HEAD is the feature branch, which may be a different commit.
|
|
133
162
|
const published = await this.refs.headSha(repoRoot, state.tmpBranch);
|
|
163
|
+
if (state.mode === push_dev_state_1.DevResolveMode.COMPOSE && published === state.baseSha) {
|
|
164
|
+
await this.restore(repoRoot, state);
|
|
165
|
+
process.stdout.write('\n' + SEP + `✅ ${state.targetRef} composes cleanly — nothing to publish\n` + SEP + '\n'
|
|
166
|
+
+ 'Every other copy merged onto it without a conflict, so your CI composes it as it is. The copy\n'
|
|
167
|
+
+ `is unchanged, and you are back on \`${state.originalBranch}\`.\n`);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
await this.gitExec.runGitChecked(['-C', repoRoot, 'push', ...this.pushSafety(state), 'origin', `${state.tmpBranch}:refs/heads/${state.targetRef}`], `Failed to publish the dev copy ${state.targetRef}`);
|
|
171
|
+
await this.restore(repoRoot, state);
|
|
172
|
+
process.stdout.write(this.publishedBanner(state)
|
|
173
|
+
+ this.watchHints.render(this.refs.config(repoRoot), state.targetRef, published));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Run the dev build on the merged throwaway. On a red build, put the checkout back first — the fix
|
|
177
|
+
* belongs on the feature branch, and a developer left parked on a throwaway would make the next
|
|
178
|
+
* `wp-*` command act on the wrong branch — then let the build's own failure (with its `FullLog :`
|
|
179
|
+
* pointer) reach the top-level handler unchanged.
|
|
180
|
+
*/
|
|
181
|
+
async buildOrRestore(repoRoot, state) {
|
|
182
|
+
process.stdout.write(`\nBuilding the merged throwaway \`${state.tmpBranch}\` before publishing.\n`);
|
|
183
|
+
// webpieces-disable no-unmanaged-exceptions -- chokepoint: the checkout must be restored whether or not the build passed; the build's own CliExitError is re-thrown unchanged
|
|
184
|
+
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
185
|
+
try {
|
|
186
|
+
await this.devBuild.run(repoRoot, rules_config_1.WP_PUSH_DEV);
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
const error = (0, to_error_1.toError)(err);
|
|
190
|
+
await this.restore(repoRoot, state);
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Turn the throwaway into what gets PUBLISHED: the base sha plus, when anything conflicted, ONE commit
|
|
196
|
+
* that sets each resolved file to its resolved content.
|
|
197
|
+
*
|
|
198
|
+
* This is issue #1397's option (a): the merge is used for the conflict check and the build only, and
|
|
199
|
+
* is never published. Publishing it would make every other copy an ancestor of this one, so a later
|
|
200
|
+
* `--remove` of that copy would leave its commits on dev through ours. The resolution commit has
|
|
201
|
+
* exactly one parent, the base, so the only thing it can carry of anybody else's work is the text of
|
|
202
|
+
* the hunks that were resolved — content, never history.
|
|
203
|
+
*/
|
|
204
|
+
async recordResolution(repoRoot, state) {
|
|
205
|
+
const merged = await this.refs.headSha(repoRoot, state.tmpBranch);
|
|
206
|
+
await this.gitExec.runGitChecked(['-C', repoRoot, 'checkout', '-B', state.tmpBranch, state.baseSha], `Failed to move ${state.tmpBranch} back to ${state.baseSha.slice(0, 8)} to record the resolution`);
|
|
207
|
+
if (state.resolvedPaths.length === 0)
|
|
208
|
+
return;
|
|
209
|
+
for (const file of state.resolvedPaths) {
|
|
210
|
+
const inMerge = await this.gitExec.tryGit(['-C', repoRoot, 'cat-file', '-e', `${merged}:${file}`], repoRoot);
|
|
211
|
+
await this.gitExec.runGitChecked(inMerge.ok
|
|
212
|
+
? ['-C', repoRoot, 'checkout', merged, '--', file]
|
|
213
|
+
: ['-C', repoRoot, 'rm', '-q', '--ignore-unmatch', '--', file], `Failed to record the resolution of ${file}`);
|
|
214
|
+
}
|
|
215
|
+
// Resolved to exactly what the base already had ("keep mine") is a resolution with nothing to record.
|
|
216
|
+
const unchanged = await this.gitExec.tryGit(['-C', repoRoot, 'diff', '--cached', '--quiet'], repoRoot);
|
|
217
|
+
if (unchanged.ok)
|
|
218
|
+
return;
|
|
219
|
+
await this.gitExec.runGitChecked(['-C', repoRoot, 'commit', '-m',
|
|
220
|
+
`${exports.RESOLUTION_SUBJECT} ${state.targetRef}\n\n`
|
|
221
|
+
+ 'This commit carries only the files that conflicted and were resolved:\n'
|
|
222
|
+
+ state.resolvedPaths.map((f) => ` ${f}`).join('\n') + '\n'], `Failed to commit the recorded resolution for ${state.targetRef}`);
|
|
223
|
+
}
|
|
224
|
+
/** Back to the original branch; the throwaway and the state file are gone. */
|
|
225
|
+
async restore(repoRoot, state) {
|
|
134
226
|
await this.gitExec.runGitChecked(['-C', repoRoot, 'checkout', state.originalBranch], `Failed to return to ${state.originalBranch}`);
|
|
135
227
|
await this.gitExec.tryGit(['-C', repoRoot, 'branch', '-D', state.tmpBranch], repoRoot);
|
|
136
228
|
this.store.clear(repoRoot);
|
|
137
|
-
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* PREBUILD leases against the sha the clobber guard inspected (plain `--force` only when asked); the
|
|
232
|
+
* other two modes overwrite the copy they themselves started from, as they always have.
|
|
233
|
+
*/
|
|
234
|
+
pushSafety(state) {
|
|
235
|
+
if (state.mode !== push_dev_state_1.DevResolveMode.PREBUILD || state.force)
|
|
236
|
+
return ['--force'];
|
|
237
|
+
if (state.leaseSha === '')
|
|
238
|
+
return [];
|
|
239
|
+
return [`--force-with-lease=refs/heads/${state.targetRef}:${state.leaseSha}`];
|
|
240
|
+
}
|
|
241
|
+
// The halt message names the build only where the finish will actually run one.
|
|
242
|
+
buildStep(state) {
|
|
243
|
+
return state.mode === push_dev_state_1.DevResolveMode.PREBUILD ? 'run the dev build, ' : '';
|
|
244
|
+
}
|
|
245
|
+
publishedBanner(state) {
|
|
246
|
+
const what = state.mode === push_dev_state_1.DevResolveMode.REPLAY
|
|
247
|
+
? 'your new commits merged with the copy\'s earlier resolution'
|
|
248
|
+
: state.resolvedPaths.length === 0
|
|
249
|
+
? 'your branch exactly as it is'
|
|
250
|
+
: `your branch plus ONE commit recording the resolution of ${String(state.resolvedPaths.length)} file(s) — no merge, so no other copy became part of its history`;
|
|
251
|
+
return '\n' + SEP + `✅ Published ${state.targetRef}\n` + SEP + '\n'
|
|
252
|
+
+ `The copy is ${what}.\n`
|
|
138
253
|
+ `You are back on \`${state.originalBranch}\`, which was never modified — verify with:\n`
|
|
139
254
|
+ ` git log --oneline ${state.originalBranch}\n`
|
|
140
255
|
+ 'Your CI will pick the copy up on its next composition run.\n'
|
|
141
|
-
+
|
|
256
|
+
+ ` ${rules_config_1.WP_PUSH_DEV} --list ← what else is in the pool\n`
|
|
257
|
+
+ ` ${rules_config_1.WP_PUSH_DEV} --remove ← take this branch back out\n`;
|
|
142
258
|
}
|
|
143
259
|
/** Conflicted (unmerged-in-index) paths. Empty once every one has been resolved and `git add`ed. */
|
|
144
260
|
async unmergedPaths(repoRoot) {
|
|
@@ -174,7 +290,18 @@ let DevResolveRunner = class DevResolveRunner {
|
|
|
174
290
|
+ `\`${state.tmpBranch}\`:\n`
|
|
175
291
|
+ state.queue.map((r) => ` ${r}`).join('\n') + '\n\n'
|
|
176
292
|
+ `Your feature branch \`${state.originalBranch}\` is not touched by any of this.\n`
|
|
177
|
-
+
|
|
293
|
+
+ 'A clean run publishes nothing (CI already composes it). A resolved conflict is published as your copy\n'
|
|
294
|
+
+ 'plus ONE commit holding the resolved files — never a merge, so no other copy enters its history.\n'
|
|
295
|
+
+ `${rules_config_1.WP_FINISH_PUSH_DEV} is only needed if a merge stops.\n\n`;
|
|
296
|
+
}
|
|
297
|
+
/** The banner plain `wp-push-dev` prints before its check against dev (#1397). */
|
|
298
|
+
announcePrebuild(cfg, state) {
|
|
299
|
+
return '\n' + SEP + `🔎 Checking ${state.targetRef} against origin/${cfg.devBranch} before publishing\n` + SEP + '\n'
|
|
300
|
+
+ `Merging origin/${cfg.devBranch} into the throwaway branch \`${state.tmpBranch}\`, then running\n`
|
|
301
|
+
+ '`commands.push-dev.buildCommand` on the merged tree. Only if both pass is the copy published — as\n'
|
|
302
|
+
+ 'your branch, plus ONE commit holding any resolved files. The merge itself is never published, so a\n'
|
|
303
|
+
+ `later \`${rules_config_1.WP_PUSH_DEV} --remove\` of somebody else's copy cannot leave it on dev through yours.\n`
|
|
304
|
+
+ `Your feature branch \`${state.originalBranch}\` is not touched by any of this.\n\n`;
|
|
178
305
|
}
|
|
179
306
|
};
|
|
180
307
|
exports.DevResolveRunner = DevResolveRunner;
|
|
@@ -183,6 +310,7 @@ exports.DevResolveRunner = DevResolveRunner = tslib_1.__decorate([
|
|
|
183
310
|
tslib_1.__metadata("design:paramtypes", [git_exec_1.GitExec,
|
|
184
311
|
dev_deploy_refs_1.DevDeployRefs,
|
|
185
312
|
push_dev_state_1.PushDevStateStore,
|
|
186
|
-
dev_deploy_watch_hints_1.DevDeployWatchHints
|
|
313
|
+
dev_deploy_watch_hints_1.DevDeployWatchHints,
|
|
314
|
+
dev_build_1.DevBuild])
|
|
187
315
|
], DevResolveRunner);
|
|
188
316
|
//# 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,0DAA4F;AAC5F,yCAA2D;AAE3D,yCAAqC;AACrC,uDAAkD;AAClD,qDAAmE;AACn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AmB;GAL3C,gBAAgB,CAgL5B","sourcesContent":["import { CliExitError, DevDeployConfig, WP_FINISH_PUSH_DEV } from '@webpieces/rules-config';\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 { DevDeployWatchHints } from './dev-deploy-watch-hints';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The queue-draining engine behind `wp-push-dev --resolve` and `wp-finish-push-dev`.\n *\n * ONE class owns every git WRITE in the resolve flow, 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 * `pr-creation-or-push-guard` blocks every `git push`. 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 merges, the commit and the push (as child processes the hooks never see); the AI's entire job is\n * editing the conflicted files and `git add`-ing them, neither of which is blocked.\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 watchHints: DevDeployWatchHints,\n ) {}\n\n /**\n * Start a resolve: park on a throwaway branch at the current copy, then drain the queue.\n *\n * The checkout is `-B <tmp> <base>` and NEVER the feature branch, which is the cardinal constraint made\n * mechanical — every merge below lands on a branch that is deleted at the end, so no other developer's\n * commits can reach the PR head even if the resolve is abandoned halfway.\n *\n * `base` differs between the two callers and the difference IS the semantics. `--resolve` starts at the\n * published copy and merges the other copies in (compose what CI will build). `--rebase-resolution`\n * starts at the LOCAL HEAD and merges the published copy in (replay an existing resolution on top of\n * the new commits, instead of force-pushing over it).\n *\n * `fetchRefs` is passed separately from the queue because `--rebase-resolution` merges a ref that is\n * also its push destination, so \"everything to fetch\" and \"everything to merge\" are not the same list.\n */\n async start(repoRoot: string, state: PushDevState, base: string, fetchRefs: string[]): Promise<void> {\n await this.refs.fetchCopies(repoRoot, fetchRefs);\n this.store.write(repoRoot, state);\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'checkout', '-B', state.tmpBranch, base],\n `Failed to create the throwaway resolve branch ${state.tmpBranch}`);\n await this.drain(repoRoot, state);\n }\n\n /**\n * Resume after the human/AI has resolved the halted merge: commit it, then keep draining.\n *\n * REFETCHES the remaining queue first. A resolution session can run long, and queuing against refs\n * fetched an hour ago rehearses a composition CI will not build — the one freshness gap the sibling\n * update flow is still known to have (only its stage ① ever fetches).\n */\n async resume(repoRoot: string, state: PushDevState): Promise<void> {\n await this.assertNoUnmergedPaths(repoRoot, state);\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 ${state.current}`);\n process.stdout.write(`✅ Committed the resolution of ${state.current}.\\n`);\n state.current = '';\n await this.refs.fetchCopies(repoRoot, state.queue);\n await this.drain(repoRoot, state);\n }\n\n /**\n * Throw the whole resolve away: undo any halted merge, go back to the original branch, delete the\n * throwaway branch and the state file. Nothing published, nothing on the feature branch.\n */\n async abort(repoRoot: string, state: PushDevState): Promise<void> {\n // Allowed to fail: there is no merge to abort when the resolve halted between merges, and that is\n // not an error condition — the rest of the teardown must still run.\n await this.gitExec.tryGit(['-C', repoRoot, 'merge', '--abort'], repoRoot);\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 process.stdout.write(\n '\\n' + SEP + '🛑 Dev-deploy resolve aborted\\n' + SEP + '\\n'\n + `You are back on \\`${state.originalBranch}\\`; \\`${state.tmpBranch}\\` and the state file are gone.\\n`\n + `The remote copy \\`${state.targetRef}\\` is untouched, and so is your feature branch.\\n`);\n }\n\n /**\n * Merge queued refs until one conflicts (HALT, hand the tree over) or the queue empties (PUBLISH).\n *\n * A LATER ref can conflict too, which is why this is a loop resumed from a state file rather than a\n * single pass: `wp-finish-push-dev` can legitimately stop again on the next ref in the queue.\n */\n private async drain(repoRoot: string, state: PushDevState): Promise<void> {\n while (state.queue.length > 0) {\n const ref = state.queue[0];\n state.queue = state.queue.slice(1);\n const outcome = await this.gitExec.tryGit(\n ['-C', repoRoot, 'merge', '--no-ff', '--no-edit', '-m',\n `Dev-deploy: merge ${ref} into ${state.targetRef}`, `refs/remotes/origin/${ref}`],\n repoRoot);\n if (outcome.ok) {\n process.stdout.write(` ✓ merged ${ref}\\n`);\n continue;\n }\n state.current = ref;\n this.store.write(repoRoot, state);\n await this.halt(repoRoot, state);\n return;\n }\n await this.publish(repoRoot, state);\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 const remaining = state.queue.length > 0\n ? `\\nStill queued after this one: ${state.queue.join(', ')}\\n`\n + `\\`${WP_FINISH_PUSH_DEV}\\` resumes the queue, so it may stop again on a later ref.\\n`\n : '';\n throw new CliExitError(2,\n '\\n' + SEP + `⚠️ CONFLICT merging ${state.current}\\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 + remaining\n + '\\nThen run ONE of:\\n'\n + ` ${WP_FINISH_PUSH_DEV} ← commit, resume the queue, publish the copy\\n`\n + ` ${WP_FINISH_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 finish command above does all three for you.\\n');\n }\n\n /** Queue empty: force-push the composed result over the copy, then restore the original checkout. */\n private async publish(repoRoot: string, state: PushDevState): Promise<void> {\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'push', '--force', 'origin', `${state.tmpBranch}:refs/heads/${state.targetRef}`],\n `Failed to publish the dev copy ${state.targetRef}`);\n // Captured BEFORE the tmp branch is deleted — it is the composed sha the watch hints are about,\n // and after the checkout below HEAD is the feature branch, which is a different commit entirely.\n const published = await this.refs.headSha(repoRoot, state.tmpBranch);\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 process.stdout.write(\n '\\n' + SEP + `✅ Published ${state.targetRef} with the resolutions\\n` + SEP + '\\n'\n + `You are back on \\`${state.originalBranch}\\`, which was never modified — verify with:\\n`\n + ` git log --oneline ${state.originalBranch}\\n`\n + 'Your CI will pick the copy up on its next composition run.\\n'\n + this.watchHints.render(this.refs.config(repoRoot), state.targetRef, published));\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 `wp-finish-push-dev`: refuse (and re-print the list) while anything is still unmerged.\n private async assertNoUnmergedPaths(repoRoot: string, state: PushDevState): 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_FINISH_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 + `Merging: ${state.current === '' ? '(none)' : state.current}\\n`\n + `Give up instead with: ${WP_FINISH_PUSH_DEV} --abort\\n`);\n }\n\n /**\n * The name of the throwaway branch for a resolve 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 `--resolve` prints before the first merge, so the queue is visible before it halts. */\n announce(cfg: DevDeployConfig, state: PushDevState): string {\n return '\\n' + SEP + `🔀 Resolving the dev composition for ${state.targetRef}\\n` + SEP + '\\n'\n + `Merging ${String(state.queue.length)} other cop${state.queue.length === 1 ? 'y' : 'ies'} from `\n + `\\`${cfg.copyRefGlob()}\\`, in the order your CI composes\\n\\`${cfg.devBranch}\\`, onto the throwaway branch `\n + `\\`${state.tmpBranch}\\`:\\n`\n + state.queue.map((r: string): string => ` ${r}`).join('\\n') + '\\n\\n'\n + `Your feature branch \\`${state.originalBranch}\\` is not touched by any of this.\\n`\n + `A clean run publishes the copy itself — ${WP_FINISH_PUSH_DEV} is only needed if a merge stops.\\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,0DAAyG;AACzG,iEAA6D;AAC7D,yCAA2D;AAE3D,yCAAqC;AACrC,uDAAkD;AAClD,qDAAmF;AACnF,qEAA+D;AAC/D,2CAAuC;AAEvC,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;GAIG;AACU,QAAA,kBAAkB,GAAG,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,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM;cACpE,yBAAyB,KAAK,CAAC,cAAc,qCAAqC;cAClF,yGAAyG;cACzG,oGAAoG;cACpG,GAAG,iCAAkB,uCAAuC,CAAC;IACvE,CAAC;IAED,kFAAkF;IAClF,gBAAgB,CAAC,GAAoB,EAAE,KAAmB;QACtD,OAAO,IAAI,GAAG,GAAG,GAAG,eAAe,KAAK,CAAC,SAAS,mBAAmB,GAAG,CAAC,SAAS,sBAAsB,GAAG,GAAG,GAAG,IAAI;cAC/G,kBAAkB,GAAG,CAAC,SAAS,gCAAgC,KAAK,CAAC,SAAS,oBAAoB;cAClG,qGAAqG;cACrG,sGAAsG;cACtG,WAAW,0BAAW,6EAA6E;cACnG,yBAAyB,KAAK,CAAC,cAAc,uCAAuC,CAAC;IAC/F,CAAC;CACJ,CAAA;AAtSY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGP,kBAAO;QACV,+BAAa;QACZ,kCAAiB;QACZ,4CAAmB;QACrB,oBAAQ;GAN9B,gBAAgB,CAsS5B","sourcesContent":["import { CliExitError, DevDeployConfig, WP_FINISH_PUSH_DEV, WP_PUSH_DEV } from '@webpieces/rules-config';\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 { DevResolveMode, PushDevState, PushDevStateStore } from './push-dev-state';\nimport { DevDeployWatchHints } from './dev-deploy-watch-hints';\nimport { DevBuild } from './dev-build';\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 * The clobber guard reads it — a remote-only commit with this subject is re-derived by the next publish's\n * check against dev, so replacing it destroys nothing; any other remote-only commit is somebody's work.\n */\nexport const RESOLUTION_SUBJECT = 'Dev-deploy: conflict resolution for';\n\n/**\n * The queue-draining engine behind `wp-push-dev` (its pre-publish check against dev, #1397),\n * `wp-push-dev --resolve`, `--rebase-resolution`, and `wp-finish-push-dev`.\n *\n * ONE class owns every git WRITE in the resolve flow, 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 * `pr-creation-or-push-guard` blocks every `git push`. 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 merges, the commit and the push (as child processes the hooks never see); the AI's entire job is\n * editing the conflicted files and `git add`-ing them, neither of which is blocked.\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 watchHints: DevDeployWatchHints,\n private readonly devBuild: DevBuild,\n ) {}\n\n /**\n * Start a resolve: park on a throwaway branch at the current copy, then drain the queue.\n *\n * The checkout is `-B <tmp> <base>` and NEVER the feature branch, which is the cardinal constraint made\n * mechanical — every merge below lands on a branch that is deleted at the end, so no other developer's\n * commits can reach the PR head even if the resolve is abandoned halfway.\n *\n * `base` differs between the callers and the difference IS the semantics. A plain publish starts at the\n * LOCAL HEAD and merges `origin/<devBranch>` in (does this copy merge and build against what is already\n * on dev?). `--resolve` starts at the published copy and merges the other copies in (compose what CI\n * will build). `--rebase-resolution` starts at the LOCAL HEAD and merges the published copy in (replay\n * an existing resolution on top of the new commits, instead of force-pushing over it). What is finally\n * PUBLISHED is the state's DevResolveMode's decision — see finalize.\n *\n * `fetchRefs` is passed separately from the queue because `--rebase-resolution` merges a ref that is\n * also its push destination, so \"everything to fetch\" and \"everything to merge\" are not the same list.\n */\n async start(repoRoot: string, state: PushDevState, base: string, fetchRefs: string[]): Promise<void> {\n await this.refs.fetchCopies(repoRoot, fetchRefs);\n // Pinned to a SHA after the fetch: the resolution is recorded on top of exactly what was merged,\n // even if the copy (or the feature branch) moves while a conflict is being resolved.\n state.baseSha = await this.refs.headSha(repoRoot, base);\n this.store.write(repoRoot, state);\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'checkout', '-B', state.tmpBranch, base],\n `Failed to create the throwaway resolve branch ${state.tmpBranch}`);\n await this.drain(repoRoot, state);\n }\n\n /**\n * Resume after the human/AI has resolved the halted merge: commit it, then keep draining.\n *\n * REFETCHES the remaining queue first. A resolution session can run long, and queuing against refs\n * fetched an hour ago rehearses a composition CI will not build — the one freshness gap the sibling\n * update flow is still known to have (only its stage ① ever fetches).\n */\n async resume(repoRoot: string, state: PushDevState): Promise<void> {\n await this.assertNoUnmergedPaths(repoRoot, state);\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 ${state.current}`);\n process.stdout.write(`✅ Committed the resolution of ${state.current}.\\n`);\n state.current = '';\n await this.refs.fetchCopies(repoRoot, state.queue);\n await this.drain(repoRoot, state);\n }\n\n /**\n * Throw the whole resolve away: undo any halted merge, go back to the original branch, delete the\n * throwaway branch and the state file. Nothing published, nothing on the feature branch.\n */\n async abort(repoRoot: string, state: PushDevState): Promise<void> {\n // Allowed to fail: there is no merge to abort when the resolve halted between merges, and that is\n // not an error condition — the rest of the teardown must still run.\n await this.gitExec.tryGit(['-C', repoRoot, 'merge', '--abort'], repoRoot);\n await this.restore(repoRoot, state);\n process.stdout.write(\n '\\n' + SEP + '🛑 Dev-deploy resolve aborted\\n' + SEP + '\\n'\n + `You are back on \\`${state.originalBranch}\\`; \\`${state.tmpBranch}\\` and the state file are gone.\\n`\n + `The remote copy \\`${state.targetRef}\\` is untouched, and so is your feature branch.\\n`);\n }\n\n /**\n * Merge queued refs until one conflicts (HALT, hand the tree over) or the queue empties (PUBLISH).\n *\n * A LATER ref can conflict too, which is why this is a loop resumed from a state file rather than a\n * single pass: `wp-finish-push-dev` can legitimately stop again on the next ref in the queue.\n */\n private async drain(repoRoot: string, state: PushDevState): Promise<void> {\n while (state.queue.length > 0) {\n const ref = state.queue[0];\n state.queue = state.queue.slice(1);\n const outcome = await this.gitExec.tryGit(\n ['-C', repoRoot, 'merge', '--no-ff', '--no-edit', '-m',\n `Dev-deploy: merge ${ref} into ${state.targetRef}`, `refs/remotes/origin/${ref}`],\n repoRoot);\n if (outcome.ok) {\n process.stdout.write(` ✓ merged ${ref}\\n`);\n continue;\n }\n state.current = ref;\n await this.halt(repoRoot, state);\n return;\n }\n await this.finalize(repoRoot, state);\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 for (const file of conflicted) if (!state.resolvedPaths.includes(file)) state.resolvedPaths.push(file);\n this.store.write(repoRoot, state);\n const remaining = state.queue.length > 0\n ? `\\nStill queued after this one: ${state.queue.join(', ')}\\n`\n + `\\`${WP_FINISH_PUSH_DEV}\\` resumes the queue, so it may stop again on a later ref.\\n`\n : '';\n throw new CliExitError(2,\n '\\n' + SEP + `⚠️ CONFLICT merging ${state.current}\\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 + remaining\n + '\\nThen run ONE of:\\n'\n + ` ${WP_FINISH_PUSH_DEV} ← commit, resume the queue, ${this.buildStep(state)}publish the copy\\n`\n + ` ${WP_FINISH_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 finish command above does all three for you.\\n');\n }\n\n /**\n * Queue empty. What happens next is the mode's (see DevResolveMode):\n *\n * - PREBUILD runs the dev build on the MERGED tree first, so a red build stops before anything is\n * published.\n * - PREBUILD and COMPOSE then publish the BASE plus the recorded resolution — never the merge. REPLAY\n * publishes the merge, as it always has.\n */\n private async finalize(repoRoot: string, state: PushDevState): Promise<void> {\n if (state.mode === DevResolveMode.PREBUILD) await this.buildOrRestore(repoRoot, state);\n if (state.mode !== DevResolveMode.REPLAY) await this.recordResolution(repoRoot, state);\n // Captured BEFORE the tmp branch is deleted — it is the sha the watch hints are about, and after\n // the restore HEAD is the feature branch, which may be a different commit.\n const published = await this.refs.headSha(repoRoot, state.tmpBranch);\n if (state.mode === DevResolveMode.COMPOSE && published === state.baseSha) {\n await this.restore(repoRoot, state);\n process.stdout.write(\n '\\n' + SEP + `✅ ${state.targetRef} composes cleanly — nothing to publish\\n` + SEP + '\\n'\n + 'Every other copy merged onto it without a conflict, so your CI composes it as it is. The copy\\n'\n + `is unchanged, and you are back on \\`${state.originalBranch}\\`.\\n`);\n return;\n }\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'push', ...this.pushSafety(state), 'origin', `${state.tmpBranch}:refs/heads/${state.targetRef}`],\n `Failed to publish the dev copy ${state.targetRef}`);\n await this.restore(repoRoot, state);\n process.stdout.write(this.publishedBanner(state)\n + this.watchHints.render(this.refs.config(repoRoot), state.targetRef, published));\n }\n\n /**\n * Run the dev build on the merged throwaway. On a red build, put the checkout back first — the fix\n * belongs on the feature branch, and a developer left parked on a throwaway would make the next\n * `wp-*` command act on the wrong branch — then let the build's own failure (with its `FullLog :`\n * pointer) reach the top-level handler unchanged.\n */\n private async buildOrRestore(repoRoot: string, state: PushDevState): Promise<void> {\n process.stdout.write(`\\nBuilding the merged throwaway \\`${state.tmpBranch}\\` before publishing.\\n`);\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: the checkout must be restored whether or not the build passed; the build's own CliExitError is re-thrown unchanged\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await this.devBuild.run(repoRoot, WP_PUSH_DEV);\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 what gets PUBLISHED: the base sha plus, when anything conflicted, ONE commit\n * that sets each resolved file to its resolved content.\n *\n * This is issue #1397's option (a): the merge is used for the conflict check and the build only, and\n * is never published. Publishing it would make every other copy an ancestor of this one, so a later\n * `--remove` of that copy would leave its commits on dev through ours. The resolution commit has\n * exactly one parent, the base, so the only thing it can carry of anybody else's work is the text of\n * the hunks that were resolved — content, 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; the throwaway and the state file are gone. */\n private async restore(repoRoot: string, state: PushDevState): Promise<void> {\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 /**\n * PREBUILD leases against the sha the clobber guard inspected (plain `--force` only when asked); the\n * other two modes overwrite the copy they themselves started from, as they always have.\n */\n private pushSafety(state: PushDevState): string[] {\n if (state.mode !== DevResolveMode.PREBUILD || state.force) return ['--force'];\n if (state.leaseSha === '') return [];\n return [`--force-with-lease=refs/heads/${state.targetRef}:${state.leaseSha}`];\n }\n\n // The halt message names the build only where the finish will actually run one.\n private buildStep(state: PushDevState): string {\n return state.mode === DevResolveMode.PREBUILD ? 'run the dev build, ' : '';\n }\n\n private publishedBanner(state: PushDevState): string {\n const what = state.mode === DevResolveMode.REPLAY\n ? 'your new commits merged with the copy\\'s earlier resolution'\n : 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 became part of its history`;\n return '\\n' + SEP + `✅ Published ${state.targetRef}\\n` + SEP + '\\n'\n + `The copy is ${what}.\\n`\n + `You are back on \\`${state.originalBranch}\\`, which was never modified — verify with:\\n`\n + ` git log --oneline ${state.originalBranch}\\n`\n + 'Your CI will pick the copy up on its next composition run.\\n'\n + ` ${WP_PUSH_DEV} --list ← what else is in the pool\\n`\n + ` ${WP_PUSH_DEV} --remove ← take this branch back out\\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 `wp-finish-push-dev`: refuse (and re-print the list) while anything is still unmerged.\n private async assertNoUnmergedPaths(repoRoot: string, state: PushDevState): 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_FINISH_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 + `Merging: ${state.current === '' ? '(none)' : state.current}\\n`\n + `Give up instead with: ${WP_FINISH_PUSH_DEV} --abort\\n`);\n }\n\n /**\n * The name of the throwaway branch for a resolve 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 `--resolve` prints before the first merge, so the queue is visible before it halts. */\n announce(cfg: DevDeployConfig, state: PushDevState): string {\n return '\\n' + SEP + `🔀 Resolving the dev composition for ${state.targetRef}\\n` + SEP + '\\n'\n + `Merging ${String(state.queue.length)} other cop${state.queue.length === 1 ? 'y' : 'ies'} from `\n + `\\`${cfg.copyRefGlob()}\\`, in the order your CI composes\\n\\`${cfg.devBranch}\\`, onto the throwaway branch `\n + `\\`${state.tmpBranch}\\`:\\n`\n + state.queue.map((r: string): string => ` ${r}`).join('\\n') + '\\n\\n'\n + `Your feature branch \\`${state.originalBranch}\\` is not touched by any of this.\\n`\n + 'A clean run publishes nothing (CI already composes it). A resolved conflict is published as your copy\\n'\n + 'plus ONE commit holding the resolved files — never a merge, so no other copy enters its history.\\n'\n + `${WP_FINISH_PUSH_DEV} is only needed if a merge stops.\\n\\n`;\n }\n\n /** The banner plain `wp-push-dev` prints before its check against dev (#1397). */\n announcePrebuild(cfg: DevDeployConfig, state: PushDevState): string {\n return '\\n' + SEP + `🔎 Checking ${state.targetRef} against origin/${cfg.devBranch} before publishing\\n` + SEP + '\\n'\n + `Merging origin/${cfg.devBranch} into the throwaway branch \\`${state.tmpBranch}\\`, then running\\n`\n + '`commands.push-dev.buildCommand` on the merged tree. Only if both pass is the copy published — as\\n'\n + 'your branch, plus ONE commit holding any resolved files. The merge itself is never published, so a\\n'\n + `later \\`${WP_PUSH_DEV} --remove\\` of somebody else's copy cannot leave it on dev through yours.\\n`\n + `Your feature branch \\`${state.originalBranch}\\` is not touched by any of this.\\n\\n`;\n }\n}\n"]}
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { DotWebpieces } from '@webpieces/tooling-common';
|
|
2
|
+
/**
|
|
3
|
+
* WHICH flow a resolve is part of — it decides what the finish publishes (#1397).
|
|
4
|
+
*
|
|
5
|
+
* - `PREBUILD` — plain `wp-push-dev`: `origin/<devBranch>` is merged into a throwaway, the dev build runs
|
|
6
|
+
* on the merged tree, and what is published is the feature head PLUS one commit recording the resolved
|
|
7
|
+
* files. The merge itself is never published.
|
|
8
|
+
* - `COMPOSE` — `wp-push-dev --resolve`: the other copies are merged into a throwaway, and what is
|
|
9
|
+
* published is the existing copy PLUS one commit recording the resolved files — never a merge parent,
|
|
10
|
+
* so no other copy becomes an ancestor of this one and a later `--remove` of it really takes it off dev.
|
|
11
|
+
* - `REPLAY` — `wp-push-dev --rebase-resolution`: the published copy is merged into the new local head
|
|
12
|
+
* and that merge IS what is published, so the copy's own resolution survives the new commits.
|
|
13
|
+
*/
|
|
14
|
+
export declare enum DevResolveMode {
|
|
15
|
+
PREBUILD = "prebuild",
|
|
16
|
+
COMPOSE = "compose",
|
|
17
|
+
REPLAY = "replay"
|
|
18
|
+
}
|
|
2
19
|
/**
|
|
3
20
|
* The persisted half of the `wp-push-dev --resolve` state machine.
|
|
4
21
|
*
|
|
@@ -20,6 +37,16 @@ export declare class PushDevState {
|
|
|
20
37
|
queue: string[];
|
|
21
38
|
/** The ref currently mid-merge (conflicted), or '' when nothing is halted. */
|
|
22
39
|
current: string;
|
|
40
|
+
/** What the finish publishes — see DevResolveMode. */
|
|
41
|
+
mode: DevResolveMode;
|
|
42
|
+
/** The sha the published copy is built ON: the feature head (PREBUILD) or the published copy (COMPOSE). */
|
|
43
|
+
baseSha: string;
|
|
44
|
+
/** Every path that conflicted and was resolved; the recorded resolution carries exactly these. */
|
|
45
|
+
resolvedPaths: string[];
|
|
46
|
+
/** The remote copy's sha when the flow started ('' = not published yet) — the push's lease. */
|
|
47
|
+
leaseSha: string;
|
|
48
|
+
/** `--force` was given: overwrite the copy without a lease. */
|
|
49
|
+
force: boolean;
|
|
23
50
|
constructor(originalBranch: string, tmpBranch: string, targetRef: string, queue: string[], current?: string);
|
|
24
51
|
}
|
|
25
52
|
/**
|