next-issue 6.6.29 → 6.6.31

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
@@ -117,9 +117,11 @@ the run handles one issue. For each issue:
117
117
  the change. When git merges the base cleanly, no agent runs. When git
118
118
  reports conflicted files, the fixer gets the list from the check budget,
119
119
  `maxCiFixes`, removes the conflict markers, and the harness commits the
120
- merge. With the budget used up, or when the fixer leaves a conflict marker
121
- or the merge unresolved, or the fixer fails, the harness undoes the merge
122
- and hands the issue to a person with the reason `merge conflict`. The
120
+ merge. A merge that the fixer commits itself counts only when the branch
121
+ then holds the base and the listed files hold no conflict marker. With the
122
+ budget used up, or when the fixer leaves a conflict marker or the merge
123
+ unresolved, aborts the merge, or fails, the harness undoes the merge and
124
+ hands the issue to a person with the reason `merge conflict`. The
123
125
  harness then pushes the commit to the base branch, without force. A push
124
126
  that the remote refuses, for example because the base moved, starts the
125
127
  rebase again, three times at most. When the push fails, the harness
package/dist/conflict.mjs CHANGED
@@ -15,6 +15,7 @@ export async function rebase(job) {
15
15
  if (merged !== undefined) {
16
16
  return merged;
17
17
  }
18
+ state.title = title;
18
19
  }
19
20
  const merged = await ports.revision(worktree);
20
21
  const squashed = await commitWork(job, merged, title, 'fixer', (cwd, message) => ports.squashOnto(cwd, base, config.remote, message));
@@ -48,7 +49,7 @@ async function resolve(job, before, files) {
48
49
  try {
49
50
  const text = files.length > 0 ? await fixConflict(job, files) : '';
50
51
  const subject = parseCommitSubject(text, `chore: merge ${config.remote}/${context.base}`);
51
- return await commitWork(job, before, subject, 'fixer', (cwd, message) => ports.commitMerge(cwd, files, message));
52
+ return await commitWork(job, before, subject, 'fixer', (cwd, message) => ports.commitMerge(cwd, { before, base: context.base, remote: config.remote, files }, message));
52
53
  }
53
54
  catch (error) {
54
55
  await ports.abortMerge(worktree, before);
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
  import { run, succeeded } from './exec.mjs';
3
3
  import { readTextOrEmpty } from './files.mjs';
4
4
  import { commitEverything } from './git-commit.mjs';
5
- import { fetchBase, git, resetHard, succeeds } from './git.mjs';
5
+ import { fetchBase, git, isAncestor, remoteRef, resetHard, succeeds } from './git.mjs';
6
6
  import { lines } from './text.mjs';
7
7
  export async function startMerge(cwd, base, remote) {
8
8
  const target = await fetchBase(cwd, base, remote);
@@ -21,13 +21,23 @@ async function merging(cwd) {
21
21
  return succeeds(cwd, ['rev-parse', '--quiet', '--verify', 'MERGE_HEAD']);
22
22
  }
23
23
  const CONFLICT_MARKER = /^(?:<{7}|>{7})(?: |$)/m;
24
- export async function commitMerge(cwd, files, message) {
25
- if (!(await merging(cwd)) || (await hasConflictMarkers(cwd, files))) {
24
+ export async function commitMerge(cwd, merge, message) {
25
+ if (!(await merging(cwd))) {
26
+ await refuseUnmerged(cwd, merge);
27
+ return false;
28
+ }
29
+ if (await hasConflictMarkers(cwd, merge.files)) {
26
30
  return false;
27
31
  }
28
32
  await commitEverything(cwd, message);
29
33
  return true;
30
34
  }
35
+ async function refuseUnmerged(cwd, merge) {
36
+ const holdsBase = await isAncestor(cwd, remoteRef(merge.remote, merge.base), 'HEAD');
37
+ if (!holdsBase || (await hasConflictMarkers(cwd, merge.files))) {
38
+ await resetHard(cwd, merge.before);
39
+ }
40
+ }
31
41
  async function hasConflictMarkers(cwd, files) {
32
42
  for (const file of files) {
33
43
  const text = await readTextOrEmpty(join(cwd, file));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.29",
3
+ "version": "6.6.31",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",