next-issue 6.6.18 → 6.6.20

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
@@ -138,7 +138,11 @@ the run handles one issue. For each issue:
138
138
  push that the remote refuses, for example because the base moved, makes
139
139
  the revert again on the new base, three times at most. A failed revert
140
140
  push that the base holds after a fetch counts as landed, and a fetch that
141
- fails leaves the revert reported as failed. A resume
141
+ fails leaves the revert reported as failed. The state file holds the
142
+ revert commit during the push, so a run stopped meanwhile checks the base
143
+ on resume. When the base holds the revert, the harness drops the landed
144
+ commits from the state, waits for no checks, does not revert again, hands
145
+ the issue to a person with the reason `revert stopped` and halts. A resume
142
146
  that stopped while the checks of a landed commit ran waits for them
143
147
  again, even when more commits landed on the base since, and a fix that
144
148
  was committed but not landed lands first. A problem that the reviewer
@@ -279,7 +283,9 @@ Every run has an id, `<timestamp>`, and writes these under `.next-issue/runs/`:
279
283
  part of the file name.
280
284
 
281
285
  At the start of a run, the harness deletes the files and folders under
282
- `.next-issue/runs/` that are older than `keepRunDays`. Set the field to `0` to keep them all.
286
+ `.next-issue/runs/` that are older than `keepRunDays`. The age of a folder is
287
+ the time since the last change to it or to anything inside it, so the sessions
288
+ of a long run stay while it still writes them. Set the field to `0` to keep them all.
283
289
 
284
290
  A short text summary of the same data goes to standard output. Use `--json` to
285
291
  get the full summary object there instead, so the harness fits in a pipe. All
@@ -1,9 +1,15 @@
1
+ import { escalateAndFinish } from './handover.mjs';
1
2
  import { ROUND_CONTINUE } from './job.mjs';
2
3
  import { resumeLanding } from './land.mjs';
3
4
  import { writeState } from './state.mjs';
4
5
  export async function enterReview(job) {
5
6
  const { context, state } = job;
6
7
  await settlePush(job);
8
+ if (await settleRevert(job)) {
9
+ job.mainBroken = true;
10
+ const { base } = context;
11
+ return escalateAndFinish(job, `The run stopped during the revert of the change on ${base}. The harness reverted the change on ${base}.`, 'revert stopped');
12
+ }
7
13
  const landed = state.landed?.at(-1);
8
14
  if (landed !== undefined) {
9
15
  return resumeLanding(job, landed);
@@ -25,3 +31,18 @@ async function settlePush(job) {
25
31
  state.pushing = undefined;
26
32
  await writeState(repo, state);
27
33
  }
34
+ async function settleRevert(job) {
35
+ const { context, state, worktree } = job;
36
+ const { repo, config, ports, base } = context;
37
+ const sha = state.reverting;
38
+ if (sha === undefined) {
39
+ return false;
40
+ }
41
+ const reverted = await ports.isOnBase(worktree, base, config.remote, sha);
42
+ if (reverted) {
43
+ state.landed = undefined;
44
+ }
45
+ state.reverting = undefined;
46
+ await writeState(repo, state);
47
+ return reverted;
48
+ }
package/dist/git-land.mjs CHANGED
@@ -35,7 +35,7 @@ export async function revertOnBase(cwd, revert) {
35
35
  }
36
36
  }
37
37
  async function pushRevert(cwd, revert) {
38
- const { base, remote, branch, shas, message, reapply } = revert;
38
+ const { base, remote, branch, shas, message, reapply, pushing } = revert;
39
39
  for (let attempt = 1; attempt <= PUSH_TRIES; attempt += 1) {
40
40
  const target = await fetchBase(cwd, base, remote);
41
41
  await git(cwd, ['checkout', '--force', '--detach', target]);
@@ -45,6 +45,7 @@ async function pushRevert(cwd, revert) {
45
45
  }
46
46
  await git(cwd, ['commit', '--no-verify', '-m', message]);
47
47
  const reverted = await revision(cwd);
48
+ await pushing(reverted);
48
49
  if ((await pushToBase(cwd, remote, base)) || (await isOnBase(cwd, base, remote, reverted))) {
49
50
  await git(cwd, ['revert', '--no-commit', reverted]);
50
51
  await git(cwd, ['commit', '--no-verify', '-m', reapply]);
@@ -1,4 +1,4 @@
1
- import { rm, stat } from 'node:fs/promises';
1
+ import { readdir, rm, stat } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { daysToMs } from './durations.mjs';
4
4
  import { listOrEmpty } from './files.mjs';
@@ -20,8 +20,7 @@ export async function pruneRuns(root, keepDays) {
20
20
  }
21
21
  async function dropIfOlder(path, cutoff) {
22
22
  try {
23
- const info = await stat(path);
24
- if (info.mtimeMs >= cutoff) {
23
+ if ((await newestChange(path)) >= cutoff) {
25
24
  return false;
26
25
  }
27
26
  await rm(path, { force: true, recursive: true });
@@ -31,3 +30,14 @@ async function dropIfOlder(path, cutoff) {
31
30
  return false;
32
31
  }
33
32
  }
33
+ async function newestChange(path) {
34
+ const info = await stat(path);
35
+ if (!info.isDirectory()) {
36
+ return info.mtimeMs;
37
+ }
38
+ let newest = info.mtimeMs;
39
+ for (const name of await readdir(path)) {
40
+ newest = Math.max(newest, await newestChange(join(path, name)));
41
+ }
42
+ return newest;
43
+ }
package/dist/revert.mjs CHANGED
@@ -34,8 +34,14 @@ export async function revert(job) {
34
34
  shas,
35
35
  message: `revert: issue #${issue.number}\n\nRefs #${issue.number}`,
36
36
  reapply: `${state.title ?? `fix: resolve issue #${issue.number}`}\n\nRefs #${issue.number}`,
37
+ pushing: async (sha) => {
38
+ state.reverting = sha;
39
+ await writeState(repo, state);
40
+ },
37
41
  }));
42
+ state.reverting = undefined;
38
43
  if (!pushed) {
44
+ await writeState(repo, state);
39
45
  return ` The revert of the change on ${base} failed, so the landed commits stay on ${base}.`;
40
46
  }
41
47
  state.landed = undefined;
package/dist/setup.mjs CHANGED
@@ -3,7 +3,6 @@ import { join } from 'node:path';
3
3
  const MARKERS = [
4
4
  ['pnpm-lock.yaml', 'pnpm install --frozen-lockfile'],
5
5
  ['package-lock.json', 'npm ci'],
6
- ['.yarnrc.yml', 'yarn install --immutable'],
7
6
  ['yarn.lock', 'yarn install --frozen-lockfile'],
8
7
  ['bun.lock', 'bun install --frozen-lockfile'],
9
8
  ['bun.lockb', 'bun install --frozen-lockfile'],
@@ -13,12 +12,18 @@ const MARKERS = [
13
12
  ['poetry.lock', 'poetry install'],
14
13
  ['Gemfile.lock', 'bundle install'],
15
14
  ];
15
+ function exists(path) {
16
+ return access(path).then(() => true, () => false);
17
+ }
16
18
  export async function detectSetupCommand(root) {
17
19
  for (const [file, command] of MARKERS) {
18
- const found = await access(join(root, file)).then(() => true, () => false);
19
- if (found) {
20
- return command;
20
+ if (!(await exists(join(root, file)))) {
21
+ continue;
22
+ }
23
+ if (file === 'yarn.lock' && (await exists(join(root, '.yarnrc.yml')))) {
24
+ return 'yarn install --immutable';
21
25
  }
26
+ return command;
22
27
  }
23
28
  return undefined;
24
29
  }
package/dist/state.mjs CHANGED
@@ -57,6 +57,7 @@ function isState(value) {
57
57
  isOptional(value.commitFixes, 'number') &&
58
58
  (value.landed === undefined || isLanded(value.landed)) &&
59
59
  isOptional(value.pushing, 'string') &&
60
+ isOptional(value.reverting, 'string') &&
60
61
  isOptional(value.rerun, 'string') &&
61
62
  typeof value.reviewRounds === 'number' &&
62
63
  Array.isArray(value.reviewLog) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.18",
3
+ "version": "6.6.20",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",