@webpieces/pr-gate 0.4.981 → 0.4.983

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.
Files changed (34) hide show
  1. package/package.json +7 -6
  2. package/src/scripts/commands/build-dev-command.d.ts +27 -0
  3. package/src/scripts/commands/build-dev-command.js +99 -0
  4. package/src/scripts/commands/build-dev-command.js.map +1 -0
  5. package/src/scripts/commands/push-dev-command.d.ts +51 -18
  6. package/src/scripts/commands/push-dev-command.js +97 -34
  7. package/src/scripts/commands/push-dev-command.js.map +1 -1
  8. package/src/scripts/pr-gate-app.d.ts +10 -2
  9. package/src/scripts/pr-gate-app.js +15 -2
  10. package/src/scripts/pr-gate-app.js.map +1 -1
  11. package/src/scripts/pr-gate-cli-app.d.ts +1 -0
  12. package/src/scripts/pr-gate-cli-app.js +11 -3
  13. package/src/scripts/pr-gate-cli-app.js.map +1 -1
  14. package/src/scripts/workflow/build-affected.d.ts +7 -0
  15. package/src/scripts/workflow/build-affected.js +12 -4
  16. package/src/scripts/workflow/build-affected.js.map +1 -1
  17. package/src/scripts/workflow/build-gate-log.d.ts +4 -2
  18. package/src/scripts/workflow/build-gate-log.js +11 -3
  19. package/src/scripts/workflow/build-gate-log.js.map +1 -1
  20. package/src/scripts/workflow/dev-build.d.ts +31 -0
  21. package/src/scripts/workflow/dev-build.js +63 -0
  22. package/src/scripts/workflow/dev-build.js.map +1 -0
  23. package/src/scripts/workflow/dev-deploy-refs.d.ts +23 -3
  24. package/src/scripts/workflow/dev-deploy-refs.js +30 -6
  25. package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
  26. package/src/scripts/workflow/dev-resolve-runner.d.ts +55 -8
  27. package/src/scripts/workflow/dev-resolve-runner.js +150 -22
  28. package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
  29. package/src/scripts/workflow/push-dev-state.d.ts +27 -0
  30. package/src/scripts/workflow/push-dev-state.js +41 -3
  31. package/src/scripts/workflow/push-dev-state.js.map +1 -1
  32. package/src/scripts/wp-build-dev.d.ts +2 -0
  33. package/src/scripts/wp-build-dev.js +13 -0
  34. package/src/scripts/wp-build-dev.js.map +1 -0
@@ -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 queue-draining engine behind `wp-push-dev --resolve` and `wp-finish-push-dev`.
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
- constructor(gitExec: GitExec, refs: DevDeployRefs, store: PushDevStateStore, watchHints: DevDeployWatchHints);
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 two callers and the difference IS the semantics. `--resolve` starts at the
30
- * published copy and merges the other copies in (compose what CI will build). `--rebase-resolution`
31
- * starts at the LOCAL HEAD and merges the published copy in (replay an existing resolution on top of
32
- * the new commits, instead of force-pushing over it).
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
- /** Queue empty: force-push the composed result over the copy, then restore the original checkout. */
61
- private publish;
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 queue-draining engine behind `wp-push-dev --resolve` and `wp-finish-push-dev`.
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
- constructor(gitExec, refs, store, watchHints) {
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 two callers and the difference IS the semantics. `--resolve` starts at the
41
- * published copy and merges the other copies in (compose what CI will build). `--rebase-resolution`
42
- * starts at the LOCAL HEAD and merges the published copy in (replay an existing resolution on top of
43
- * the new commits, instead of force-pushing over it).
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.gitExec.runGitChecked(['-C', repoRoot, 'checkout', state.originalBranch], `Failed to return to ${state.originalBranch}`);
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.publish(repoRoot, state);
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
- /** Queue empty: force-push the composed result over the copy, then restore the original checkout. */
129
- async publish(repoRoot, state) {
130
- await this.gitExec.runGitChecked(['-C', repoRoot, 'push', '--force', 'origin', `${state.tmpBranch}:refs/heads/${state.targetRef}`], `Failed to publish the dev copy ${state.targetRef}`);
131
- // Captured BEFORE the tmp branch is deleted — it is the composed sha the watch hints are about,
132
- // and after the checkout below HEAD is the feature branch, which is a different commit entirely.
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
- process.stdout.write('\n' + SEP + `✅ Published ${state.targetRef} with the resolutions\n` + SEP + '\n'
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
- + this.watchHints.render(this.refs.config(repoRoot), state.targetRef, published));
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
- + `A clean run publishes the copy itself — ${rules_config_1.WP_FINISH_PUSH_DEV} is only needed if a merge stops.\n\n`;
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;AACnE,qEAA+D;AAE/D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;GASG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEJ;IACA;IACA;IACA;IAJrB,YACqB,OAAgB,EAChB,IAAmB,EACnB,KAAwB,EACxB,UAA+B;QAH/B,YAAO,GAAP,OAAO,CAAS;QAChB,SAAI,GAAJ,IAAI,CAAe;QACnB,UAAK,GAAL,KAAK,CAAmB;QACxB,eAAU,GAAV,UAAU,CAAqB;IACjD,CAAC;IAEJ;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,KAAmB,EAAE,IAAY,EAAE,SAAmB;QAChF,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAClC,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAC5B,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,EACzD,iDAAiD,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACxE,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,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S,EAAU,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM;cACpE,yBAAyB,KAAK,CAAC,cAAc,qCAAqC;cAClF,2CAA2C,iCAAkB,uCAAuC,CAAC;IAC/G,CAAC;CACJ,CAAA;AAhLY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGP,kBAAO;QACV,+BAAa;QACZ,kCAAiB;QACZ,4CAAmB;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,qCAAqC,CAAC;AAExE;;;;;;;;;;GAUG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEJ;IACA;IACA;IACA;IACA;IALrB,YACqB,OAAgB,EAChB,IAAmB,EACnB,KAAwB,EACxB,UAA+B,EAC/B,QAAkB;QAJlB,YAAO,GAAP,OAAO,CAAS;QAChB,SAAI,GAAJ,IAAI,CAAe;QACnB,UAAK,GAAL,KAAK,CAAmB;QACxB,eAAU,GAAV,UAAU,CAAqB;QAC/B,aAAQ,GAAR,QAAQ,CAAU;IACpC,CAAC;IAEJ;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,KAAmB,EAAE,IAAY,EAAE,SAAmB;QAChF,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACjD,iGAAiG;QACjG,qFAAqF;QACrF,KAAK,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAClC,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAC5B,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,EACzD,iDAAiD,KAAK,CAAC,SAA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AAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ;cAChG,KAAK,GAAG,CAAC,WAAW,EAAE,wCAAwC,GAAG,CAAC,SAAS,gCAAgC;cAC3G,KAAK,KAAK,CAAC,SAAS,OAAO;cAC3B,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,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
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PushDevStateStore = exports.PushDevState = void 0;
3
+ exports.PushDevStateStore = exports.PushDevState = exports.DevResolveMode = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fs = tslib_1.__importStar(require("fs"));
6
6
  const rules_config_1 = require("@webpieces/rules-config");
@@ -8,6 +8,24 @@ const tooling_common_1 = require("@webpieces/tooling-common");
8
8
  const to_error_1 = require("@webpieces/tooling-common/to-error");
9
9
  const inversify_1 = require("inversify");
10
10
  const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
11
+ /**
12
+ * WHICH flow a resolve is part of — it decides what the finish publishes (#1397).
13
+ *
14
+ * - `PREBUILD` — plain `wp-push-dev`: `origin/<devBranch>` is merged into a throwaway, the dev build runs
15
+ * on the merged tree, and what is published is the feature head PLUS one commit recording the resolved
16
+ * files. The merge itself is never published.
17
+ * - `COMPOSE` — `wp-push-dev --resolve`: the other copies are merged into a throwaway, and what is
18
+ * published is the existing copy PLUS one commit recording the resolved files — never a merge parent,
19
+ * so no other copy becomes an ancestor of this one and a later `--remove` of it really takes it off dev.
20
+ * - `REPLAY` — `wp-push-dev --rebase-resolution`: the published copy is merged into the new local head
21
+ * and that merge IS what is published, so the copy's own resolution survives the new commits.
22
+ */
23
+ var DevResolveMode;
24
+ (function (DevResolveMode) {
25
+ DevResolveMode["PREBUILD"] = "prebuild";
26
+ DevResolveMode["COMPOSE"] = "compose";
27
+ DevResolveMode["REPLAY"] = "replay";
28
+ })(DevResolveMode || (exports.DevResolveMode = DevResolveMode = {}));
11
29
  /**
12
30
  * The persisted half of the `wp-push-dev --resolve` state machine.
13
31
  *
@@ -29,6 +47,16 @@ class PushDevState {
29
47
  queue;
30
48
  /** The ref currently mid-merge (conflicted), or '' when nothing is halted. */
31
49
  current;
50
+ /** What the finish publishes — see DevResolveMode. */
51
+ mode = DevResolveMode.COMPOSE;
52
+ /** The sha the published copy is built ON: the feature head (PREBUILD) or the published copy (COMPOSE). */
53
+ baseSha = '';
54
+ /** Every path that conflicted and was resolved; the recorded resolution carries exactly these. */
55
+ resolvedPaths = [];
56
+ /** The remote copy's sha when the flow started ('' = not published yet) — the push's lease. */
57
+ leaseSha = '';
58
+ /** `--force` was given: overwrite the copy without a lease. */
59
+ force = false;
32
60
  // eslint-disable-next-line @typescript-eslint/max-params
33
61
  constructor(originalBranch, tmpBranch, targetRef, queue, current = '') {
34
62
  this.originalBranch = originalBranch;
@@ -45,9 +73,11 @@ exports.PushDevState = PushDevState;
45
73
  // survives every edit to the actual enforcement and ends up forbidding things the flow requires.
46
74
  //
47
75
  // Why these and not everything: each one either rewrites the current branch (the two starts), pushes it
48
- // (the finishes), or deletes branches (cleanup) — and during a resolve the checkout is a throwaway
76
+ // (the finishes), deletes branches (cleanup), or parks the checkout on a throwaway of its own
77
+ // (wp-build-dev) — and during a resolve the checkout is a throwaway
49
78
  // branch, not the feature branch any of them think they are acting on.
50
79
  const BLOCKED_DURING_RESOLVE = [
80
+ 'wp-build-dev',
51
81
  'wp-start-update',
52
82
  'wp-finish-update',
53
83
  'wp-start-upsert-pr',
@@ -89,7 +119,15 @@ let PushDevStateStore = class PushDevStateStore {
89
119
  const raw = JSON.parse(fs.readFileSync(file, 'utf8'));
90
120
  if (typeof raw.originalBranch !== 'string' || typeof raw.tmpBranch !== 'string')
91
121
  return null;
92
- return new PushDevState(raw.originalBranch, raw.tmpBranch, raw.targetRef ?? '', Array.isArray(raw.queue) ? raw.queue : [], raw.current ?? '');
122
+ const state = new PushDevState(raw.originalBranch, raw.tmpBranch, raw.targetRef ?? '', Array.isArray(raw.queue) ? raw.queue : [], raw.current ?? '');
123
+ state.mode = Object.values(DevResolveMode).includes(raw.mode)
124
+ ? raw.mode
125
+ : DevResolveMode.COMPOSE;
126
+ state.baseSha = typeof raw.baseSha === 'string' ? raw.baseSha : '';
127
+ state.resolvedPaths = Array.isArray(raw.resolvedPaths) ? raw.resolvedPaths : [];
128
+ state.leaseSha = typeof raw.leaseSha === 'string' ? raw.leaseSha : '';
129
+ state.force = raw.force === true;
130
+ return state;
93
131
  // The parse error carries nothing a caller could act on: the ONLY meaningful reading of an
94
132
  // unparseable state file is "no resolve in progress", which --abort and a fresh --resolve both
95
133
  // recover from.