next-issue 8.2.1 → 8.2.2

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/README.md CHANGED
@@ -163,9 +163,16 @@ the run handles one issue. For each issue:
163
163
  `merge conflict`. When `checks` lists commands, the harness then runs
164
164
  the setup command again in the worktree, so the checks use the
165
165
  dependencies of the merged base. It runs the setup after it makes the
166
- change one commit, and adds what the setup writes, unless git ignores
167
- it, to that commit without hooks. Every check runs on that commit, and
168
- the base gets the same files that the checks passed on. A change that
166
+ change one commit, and commits what the setup writes, unless git
167
+ ignores it, on top of that commit without hooks. Every check runs on
168
+ that setup commit. After the checks, the harness puts the branch back
169
+ at the change commit, so what this setup writes does not land on the
170
+ base; after a stop or kill during the checks, the next run puts the
171
+ branch back first. What the first setup writes, before the
172
+ implementer, is part of the implementer's commit and lands. When this
173
+ setup rewrites such a file, for example a lock file, the checks run on
174
+ the rewritten file, but the base gets the file of the change.
175
+ A change that
169
176
  the base already holds is an `empty change` before the setup runs. A
170
177
  setup that fails or does not finish in `setupTimeoutMinutes` keeps the
171
178
  merged commit, stops the landing before the push and hands the
package/dist/git.mjs CHANGED
@@ -107,13 +107,9 @@ export async function saveEdits(cwd, commitMessage) {
107
107
  await git(cwd, ['commit', '--no-verify', '-m', commitMessage]);
108
108
  return true;
109
109
  }
110
- /** Adds every edit in the worktree to the last commit, with no hooks. */
111
- export async function amendEdits(cwd) {
112
- if (!(await isDirty(cwd))) {
113
- return;
114
- }
115
- await git(cwd, ['add', '-A']);
116
- await git(cwd, ['commit', '--amend', '--no-edit', '--no-verify']);
110
+ /** Commits what the setup wrote on top of the change, with no hooks, so every check sees it. */
111
+ export async function saveSetupOutput(cwd) {
112
+ await saveEdits(cwd, 'chore: setup output');
117
113
  }
118
114
  export async function setAside(cwd, target, branch) {
119
115
  await git(cwd, ['branch', branch]);
@@ -14,16 +14,33 @@ const COMMENT_OUTPUT_CHARS = 3000;
14
14
  * or the finished hand-over.
15
15
  */
16
16
  export async function localChecks(job) {
17
- const { context, log, worktree } = job;
18
- const { config, ports } = context;
17
+ const { context, state, worktree } = job;
18
+ const { config, ports, repo } = context;
19
19
  if (config.checks.length === 0) {
20
20
  return true;
21
21
  }
22
+ const change = await ports.revision(worktree);
22
23
  const setup = await setUpBeforeChecks(job);
23
24
  if (setup !== undefined) {
24
25
  return setup;
25
26
  }
26
- await ports.amendEdits(worktree);
27
+ state.squashing = change;
28
+ await writeState(repo, state);
29
+ await ports.saveSetupOutput(worktree);
30
+ let failed;
31
+ try {
32
+ failed = await runChecks(job);
33
+ }
34
+ finally {
35
+ await evenWhenStopped(() => ports.discardChanges(worktree, change));
36
+ state.squashing = undefined;
37
+ await writeState(repo, state);
38
+ }
39
+ return failed === undefined ? true : failedCheck(job, failed.command, failed.result);
40
+ }
41
+ async function runChecks(job) {
42
+ const { context, log, worktree } = job;
43
+ const { config, ports } = context;
27
44
  const head = await ports.revision(worktree);
28
45
  for (const command of config.checks) {
29
46
  const result = await log.step('check', { cmd: command }, () => ports.runCheck(command, worktree, minutesToMs(config.checksTimeoutMinutes), config.logMaxChars));
@@ -32,10 +49,10 @@ export async function localChecks(job) {
32
49
  refuseWhenStopped();
33
50
  log.event('check.output', { cmd: command, code: result.code, timedOut: result.timedOut, output: result.output }, 'verbose');
34
51
  if (!succeeded(result) || result.timedOut) {
35
- return failedCheck(job, command, result);
52
+ return { command, result };
36
53
  }
37
54
  }
38
- return true;
55
+ return undefined;
39
56
  }
40
57
  function failure(job, command, result) {
41
58
  return result.timedOut
package/dist/ports.mjs CHANGED
@@ -4,7 +4,7 @@ import { run } from './exec.mjs';
4
4
  import { commitAll } from './git-commit.mjs';
5
5
  import { pushToBase, reapplyRevert, revertOnBase, squashOnto } from './git-land.mjs';
6
6
  import { abortMerge, commitMerge, startMerge } from './git-merge.mjs';
7
- import { amendEdits, changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, setAside, } from './git.mjs';
7
+ import { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, saveSetupOutput, setAside, } from './git.mjs';
8
8
  import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueComments, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
9
9
  import { huntWorktree } from './hunt.mjs';
10
10
  import { ensureLabel, setLabel } from './labels.mjs';
@@ -20,7 +20,6 @@ async function runCheck(command, cwd, timeoutMs, tailChars) {
20
20
  }
21
21
  export const PORTS = {
22
22
  abortMerge,
23
- amendEdits,
24
23
  addWorktree,
25
24
  canWrite,
26
25
  changedFiles,
@@ -60,6 +59,7 @@ export const PORTS = {
60
59
  runCheck,
61
60
  runSetup,
62
61
  saveEdits,
62
+ saveSetupOutput,
63
63
  setAside,
64
64
  setLabel,
65
65
  squashOnto,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "8.2.1",
3
+ "version": "8.2.2",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",