next-issue 7.8.14 → 7.8.16

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
@@ -160,8 +160,13 @@ the run handles one issue. For each issue:
160
160
  harness undoes the merge and hands the issue to a person with the reason
161
161
  `merge conflict`. When `checks` lists commands, the harness then runs
162
162
  the setup command again in the worktree, so the checks use the
163
- dependencies of the merged base. A setup that fails or does not finish
164
- in `setupTimeoutMinutes` stops the landing before the push and hands the
163
+ dependencies of the merged base. It runs the setup after it makes the
164
+ change one commit, and adds what the setup writes, unless git ignores
165
+ it, to that commit without hooks. Every check runs on that commit, and
166
+ the base gets the same files that the checks passed on. A change that
167
+ the base already holds is an `empty change` before the setup runs. A
168
+ setup that fails or does not finish in `setupTimeoutMinutes` keeps the
169
+ merged commit, stops the landing before the push and hands the
165
170
  issue to a person with the reason `setup failed` or `setup timeout`. The
166
171
  harness then runs each command in `checks` in the worktree, in order,
167
172
  with `bash -c` and stderr merged into stdout, each for at most
@@ -396,7 +401,8 @@ A halt that leaves a commit on the base, or a push or revert that may be on
396
401
  it, with checks nobody awaited (`checks error`, `push unknown`,
397
402
  `main checks timeout`, `main checks cancelled`, an error or a failed setup
398
403
  on such a resume before the base is checked, or a stop or kill while the run
399
- pushes a change to the base or waits for the checks of a commit it landed) is
404
+ pushes a change to the base, waits for the checks of a commit it landed, or
405
+ fixes the failed checks of that commit before the fix lands) is
400
406
  saved in the state file of its issue. A stopped issue resumes in the next
401
407
  run; any other waits for a person, so later runs skip it. Either way, no
402
408
  later run lands another change meanwhile: an issue that reaches the landing
package/dist/gate.mjs CHANGED
@@ -5,7 +5,7 @@ import { asError, message } from './errors.mjs';
5
5
  import { escalateCheckFix, fixRound } from './fix.mjs';
6
6
  import { escalateAndFinish } from './handover.mjs';
7
7
  import { GATE_FIXED, GATE_PASSED } from './job.mjs';
8
- import { revertOrReport, sentence } from './revert.mjs';
8
+ import { revertFailedChecks, revertOrReport, sentence } from './revert.mjs';
9
9
  import { writeState } from './state.mjs';
10
10
  import { HALT_NOTE } from './unsettled.mjs';
11
11
  export async function checkGate(job, sha) {
@@ -20,13 +20,12 @@ export async function checkGate(job, sha) {
20
20
  }
21
21
  return unreadChecks(job, error);
22
22
  }
23
- // Checks that finished leave the base known, so an earlier halt on this issue no longer holds back other landings.
24
- const finished = checks === 'pass' || checks === 'none' || checks === 'fail';
25
- if (finished && job.state.halted === true) {
26
- delete job.state.halted;
27
- await writeState(job.context.repo, job.state);
28
- }
23
+ // Checks that passed leave the base known, so an earlier halt on this issue no longer holds back other landings.
29
24
  if (checks === 'pass' || checks === 'none') {
25
+ if (job.state.halted === true) {
26
+ delete job.state.halted;
27
+ await writeState(job.context.repo, job.state);
28
+ }
30
29
  return GATE_PASSED;
31
30
  }
32
31
  job.mainBroken = true;
@@ -40,6 +39,9 @@ export async function checkGate(job, sha) {
40
39
  if (checks !== 'fail') {
41
40
  return escalateAndFinish(job, `The checks on ${base} did not finish in time. ${HALT_NOTE}`, 'main checks timeout');
42
41
  }
42
+ // Failed checks leave the base broken until the fix lands, so a stop or kill before then keeps other landings back.
43
+ job.state.halted = true;
44
+ await writeState(job.context.repo, job.state);
43
45
  return failedChecksFix(job, sha);
44
46
  }
45
47
  async function waitForChecks(job, sha, fields = {}, restarted = []) {
@@ -96,7 +98,7 @@ async function failedChecksFix(job, sha, refused) {
96
98
  const { repo, config, ports, base } = context;
97
99
  const { round, limit } = budgetUse(job, 'ciFixes');
98
100
  if (round >= limit) {
99
- const reverted = await revertOrReport(job);
101
+ const reverted = await revertFailedChecks(job);
100
102
  return escalateAndFinish(job, `The checks on ${base} failed and the limit of ${limit} check fixes was reached.${reverted}`, 'check budget');
101
103
  }
102
104
  state.ciFixes += 1;
@@ -133,7 +135,7 @@ async function failedChecksFix(job, sha, refused) {
133
135
  }
134
136
  }
135
137
  if (!fix.committed) {
136
- const reverted = await revertOrReport(job);
138
+ const reverted = await revertFailedChecks(job);
137
139
  return escalateCheckFix(job, fix.unrelated, `checks on ${base}`, reverted, fix.aside);
138
140
  }
139
141
  job.repairing = true;
@@ -188,6 +190,6 @@ export async function escalateError(job, error, note, reason) {
188
190
  if (runStopped()) {
189
191
  throw error;
190
192
  }
191
- const reverted = await revertOrReport(job);
193
+ const reverted = await revertFailedChecks(job);
192
194
  return escalateAndFinish(job, `${note}: ${sentence(message(error))}${reverted}`, reason);
193
195
  }
package/dist/git.mjs CHANGED
@@ -107,6 +107,14 @@ 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']);
117
+ }
110
118
  export async function setAside(cwd, target, branch) {
111
119
  await git(cwd, ['branch', branch]);
112
120
  if (await isDirty(cwd)) {
@@ -23,6 +23,7 @@ export async function localChecks(job) {
23
23
  if (setup !== undefined) {
24
24
  return setup;
25
25
  }
26
+ await ports.amendEdits(worktree);
26
27
  const head = await ports.revision(worktree);
27
28
  for (const command of config.checks) {
28
29
  const result = await log.step('check', { cmd: command }, () => ports.runCheck(command, worktree, minutesToMs(config.checksTimeoutMinutes), config.logMaxChars));
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 { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, setAside, } from './git.mjs';
7
+ import { amendEdits, changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, 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,6 +20,7 @@ async function runCheck(command, cwd, timeoutMs, tailChars) {
20
20
  }
21
21
  export const PORTS = {
22
22
  abortMerge,
23
+ amendEdits,
23
24
  addWorktree,
24
25
  canWrite,
25
26
  changedFiles,
package/dist/revert.mjs CHANGED
@@ -7,6 +7,15 @@ export async function revertFailedFix(job) {
7
7
  return '';
8
8
  }
9
9
  job.repairing = false;
10
+ return revertFailedChecks(job);
11
+ }
12
+ /** Hands over a fix of failed checks; with no stop, its saved halt gives way, so the run halt alone holds back other landings. */
13
+ export async function revertFailedChecks(job) {
14
+ const { context, state } = job;
15
+ if (state.halted === true && state.pushing === undefined && !runStopped()) {
16
+ delete state.halted;
17
+ await writeState(context.repo, state);
18
+ }
10
19
  return revertOrReport(job);
11
20
  }
12
21
  export async function revertOrReport(job) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "7.8.14",
3
+ "version": "7.8.16",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",