@ai-ecoverse/slicc-shared-web 1.30.4 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/unit/merge.mjs +28 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-shared-web",
3
- "version": "1.30.4",
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
@@ -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
- if (views.includes(undefined)) return undefined;
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
- rest.every((other) => other.get(name)?.marks.has(entry))
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)