@ai-ecoverse/slicc-shared-web 1.30.3 → 1.30.5
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/package.json +1 -1
- package/unit/merge.mjs +29 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.5",
|
|
4
4
|
"description": "Shared Renovate, Biome, TypeScript, lefthook and GitHub Actions configuration, plus the CDP integration-test harness, for SLICC's web repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
package/unit/merge.mjs
CHANGED
|
@@ -52,7 +52,6 @@ function mark(file, found) {
|
|
|
52
52
|
file.hunks = true;
|
|
53
53
|
const start = Number(found[1]);
|
|
54
54
|
const count = found[2] === undefined ? 1 : Number(found[2]);
|
|
55
|
-
if (count === 0) file.marks.add(`^${start}`);
|
|
56
55
|
for (let at = start; at < start + count; at++) file.marks.add(`+${at}`);
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -67,6 +66,7 @@ export function marks(text) {
|
|
|
67
66
|
if (!file) continue;
|
|
68
67
|
const found = hunk.exec(line);
|
|
69
68
|
if (found) mark(file, found);
|
|
69
|
+
else if (file.hunks && line.startsWith('-')) file.marks.add(line);
|
|
70
70
|
else if (!file.hunks && (line.startsWith('--- ') || line.startsWith('+++ '))) {
|
|
71
71
|
const named = path(line.slice(4));
|
|
72
72
|
if (named !== undefined) file.paths.push(named);
|
|
@@ -93,21 +93,46 @@ export function parents(root) {
|
|
|
93
93
|
return [...merging, ...picked];
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
export function renames(text) {
|
|
97
|
+
const moved = new Map();
|
|
98
|
+
const parts = text.split('\0');
|
|
99
|
+
for (let at = 0; at < parts.length; at += 2) {
|
|
100
|
+
if (!parts[at].startsWith('R')) continue;
|
|
101
|
+
moved.set(parts[at + 1], parts[at + 2]);
|
|
102
|
+
at += 1;
|
|
103
|
+
}
|
|
104
|
+
return moved;
|
|
105
|
+
}
|
|
106
|
+
|
|
96
107
|
export function merged(root = process.cwd()) {
|
|
97
108
|
const others = parents(root);
|
|
98
109
|
if (others.length === 0) return undefined;
|
|
99
110
|
const views = ['HEAD', ...others].map((parent) => git(root, [...diff, parent]));
|
|
100
|
-
|
|
111
|
+
const moves = others.map((parent) =>
|
|
112
|
+
git(root, [
|
|
113
|
+
'diff',
|
|
114
|
+
'--no-ext-diff',
|
|
115
|
+
'--no-relative',
|
|
116
|
+
'-M',
|
|
117
|
+
'--name-status',
|
|
118
|
+
'-z',
|
|
119
|
+
'HEAD',
|
|
120
|
+
parent,
|
|
121
|
+
])
|
|
122
|
+
);
|
|
123
|
+
if ([...views, ...moves].includes(undefined)) return undefined;
|
|
101
124
|
const [base, ...rest] = views.map(marks);
|
|
125
|
+
const moved = moves.map(renames);
|
|
102
126
|
const prefix = git(root, ['rev-parse', '--show-prefix'])?.trim() ?? '';
|
|
103
127
|
const files = new Set();
|
|
104
128
|
let text = '';
|
|
105
129
|
for (const [name, file] of base) {
|
|
130
|
+
const matches = rest.map((other, at) => other.get(name) ?? other.get(moved[at].get(name)));
|
|
106
131
|
const kept = [...file.marks].filter((entry) =>
|
|
107
|
-
|
|
132
|
+
matches.every((other) => other?.marks.has(entry))
|
|
108
133
|
);
|
|
109
134
|
if (kept.length === 0) continue;
|
|
110
|
-
for (const each of file.paths)
|
|
135
|
+
for (const each of [file, ...matches].flatMap((one) => one.paths))
|
|
111
136
|
if (each.startsWith(prefix)) files.add(each.slice(prefix.length));
|
|
112
137
|
const lines = kept.filter((entry) => entry.startsWith('+')).map((entry) => entry.slice(1));
|
|
113
138
|
if (lines.length > 0)
|