next-issue 6.6.119 → 6.6.121
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 +4 -0
- package/dist/config.mjs +17 -0
- package/dist/git-merge.mjs +31 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -596,6 +596,10 @@ because no pull request is opened.
|
|
|
596
596
|
The hunter adds `labels.hunt` to each issue it files, so you can tell those
|
|
597
597
|
issues apart from your own and filter them.
|
|
598
598
|
|
|
599
|
+
The names in `labels.ready`, `inProgress`, `inReview`, `done`, `needsHuman`
|
|
600
|
+
and `skip` must be distinct, also when case is ignored; two equal names stop
|
|
601
|
+
the run with an error that names both fields. `labels.hunt` may share a name.
|
|
602
|
+
|
|
599
603
|
An empty `labels.ready` turns the ready requirement off. The harness then
|
|
600
604
|
claims every open issue that no other label holds back.
|
|
601
605
|
|
package/dist/config.mjs
CHANGED
|
@@ -166,8 +166,25 @@ function parseLabels(value, defaultLabels) {
|
|
|
166
166
|
parsed[name] = text(labels[name], `labels.${name}`, name === 'ready');
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
+
rejectSameLabels(parsed);
|
|
169
170
|
return parsed;
|
|
170
171
|
}
|
|
172
|
+
// Label checks ignore case, so two status labels that match without case would
|
|
173
|
+
// make the harness read one status as another.
|
|
174
|
+
function rejectSameLabels(labels) {
|
|
175
|
+
const seen = new Map();
|
|
176
|
+
for (const name of LABEL_NAMES) {
|
|
177
|
+
if (name === 'hunt' || labels[name] === '') {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const key = labels[name].toLowerCase();
|
|
181
|
+
const other = seen.get(key);
|
|
182
|
+
if (other !== undefined) {
|
|
183
|
+
throw new Error(`${CONFIG_FILE}: labels.${other} and labels.${name} must be different labels, but both are ${labels[name]} when case is ignored.`);
|
|
184
|
+
}
|
|
185
|
+
seen.set(key, name);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
171
188
|
export function managedLabels(config) {
|
|
172
189
|
return LABEL_NAMES.filter((name) => name !== 'skip' && name !== 'hunt').map((name) => config.labels[name]);
|
|
173
190
|
}
|
package/dist/git-merge.mjs
CHANGED
|
@@ -5,7 +5,9 @@ import { commitEverything } from './git-commit.mjs';
|
|
|
5
5
|
import { fetchBase, git, isAncestor, resetHard, succeeds } from './git.mjs';
|
|
6
6
|
export async function startMerge(cwd, base, remote) {
|
|
7
7
|
const target = await git(cwd, ['rev-parse', await fetchBase(cwd, base, remote)]);
|
|
8
|
-
const result = await run('git', ['merge', '--no-ff', '--no-commit', target], {
|
|
8
|
+
const result = await run('git', [...NO_RERERE, 'merge', '--no-ff', '--no-commit', target], {
|
|
9
|
+
cwd,
|
|
10
|
+
});
|
|
9
11
|
if (succeeded(result)) {
|
|
10
12
|
return { target, files: (await merging(cwd)) ? [] : undefined, unmarked: [] };
|
|
11
13
|
}
|
|
@@ -15,12 +17,14 @@ export async function startMerge(cwd, base, remote) {
|
|
|
15
17
|
}
|
|
16
18
|
const unmarked = [];
|
|
17
19
|
for (const file of files) {
|
|
18
|
-
if (!(await hasConflictMarkers(cwd, [file]))) {
|
|
20
|
+
if (!(await hasConflictMarkers(cwd, [file], 'HEAD'))) {
|
|
19
21
|
unmarked.push(file);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
return { target, files, unmarked };
|
|
23
25
|
}
|
|
26
|
+
// A recorded resolution would hide the conflict markers from the fixer.
|
|
27
|
+
const NO_RERERE = ['-c', 'rerere.enabled=false', '-c', 'rerere.autoUpdate=false'];
|
|
24
28
|
async function unmergedFiles(cwd) {
|
|
25
29
|
const args = ['diff', '--name-only', '-z', '--diff-filter=U'];
|
|
26
30
|
const listed = await run('git', args, { cwd });
|
|
@@ -32,13 +36,30 @@ async function unmergedFiles(cwd) {
|
|
|
32
36
|
async function merging(cwd) {
|
|
33
37
|
return succeeds(cwd, ['rev-parse', '--quiet', '--verify', 'MERGE_HEAD']);
|
|
34
38
|
}
|
|
35
|
-
const
|
|
39
|
+
const DEFAULT_MARKER_SIZE = 7;
|
|
40
|
+
function conflictMarker(size) {
|
|
41
|
+
return new RegExp(`^(?:<{${size}}|>{${size}})(?: |$)`, 'm');
|
|
42
|
+
}
|
|
43
|
+
// git writes the markers with the attributes of the branch's own commit, while the merged
|
|
44
|
+
// base or the fixer can change them in the worktree, so both sizes count.
|
|
45
|
+
async function markerSizes(cwd, file, before) {
|
|
46
|
+
return new Set([await markerSize(cwd, file, ['--source', before]), await markerSize(cwd, file)]);
|
|
47
|
+
}
|
|
48
|
+
async function markerSize(cwd, file, source = []) {
|
|
49
|
+
const args = ['check-attr', '-z', ...source, 'conflict-marker-size', '--', file];
|
|
50
|
+
const result = await run('git', args, { cwd });
|
|
51
|
+
if (!succeeded(result)) {
|
|
52
|
+
throw new Error(failedWith(`git ${args.join(' ')}`, result));
|
|
53
|
+
}
|
|
54
|
+
const value = Number(result.stdout.split('\0')[2]);
|
|
55
|
+
return Number.isInteger(value) && value > 0 ? value : DEFAULT_MARKER_SIZE;
|
|
56
|
+
}
|
|
36
57
|
export async function commitMerge(cwd, merge, message) {
|
|
37
58
|
if (!(await merging(cwd))) {
|
|
38
59
|
await refuseUnmerged(cwd, merge);
|
|
39
60
|
return false;
|
|
40
61
|
}
|
|
41
|
-
if (await hasConflictMarkers(cwd, merge.files)) {
|
|
62
|
+
if (await hasConflictMarkers(cwd, merge.files, merge.before)) {
|
|
42
63
|
return false;
|
|
43
64
|
}
|
|
44
65
|
await commitEverything(cwd, message);
|
|
@@ -46,15 +67,17 @@ export async function commitMerge(cwd, merge, message) {
|
|
|
46
67
|
}
|
|
47
68
|
async function refuseUnmerged(cwd, merge) {
|
|
48
69
|
const holdsBase = await isAncestor(cwd, merge.target, 'HEAD');
|
|
49
|
-
if (!holdsBase || (await hasConflictMarkers(cwd, merge.files))) {
|
|
70
|
+
if (!holdsBase || (await hasConflictMarkers(cwd, merge.files, merge.before))) {
|
|
50
71
|
await resetHard(cwd, merge.before);
|
|
51
72
|
}
|
|
52
73
|
}
|
|
53
|
-
async function hasConflictMarkers(cwd, files) {
|
|
74
|
+
async function hasConflictMarkers(cwd, files, before) {
|
|
54
75
|
for (const file of files) {
|
|
55
76
|
const text = await readTextOrEmpty(join(cwd, file));
|
|
56
|
-
|
|
57
|
-
|
|
77
|
+
for (const size of await markerSizes(cwd, file, before)) {
|
|
78
|
+
if (conflictMarker(size).test(text)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
58
81
|
}
|
|
59
82
|
}
|
|
60
83
|
return false;
|