@feng0531/dsh-code-review 0.29.1 → 0.29.2
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/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/git.mjs +13 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
package/src/git.mjs
CHANGED
|
@@ -22,14 +22,7 @@ export async function captureGit(cwd, options = {}) {
|
|
|
22
22
|
if (ref.code !== 1) throw new Error('Cannot resolve Git HEAD');
|
|
23
23
|
}
|
|
24
24
|
const base = new Map();
|
|
25
|
-
|
|
26
|
-
const tree = text(await git(root, ['ls-tree', '-rz', '--full-tree', head], options));
|
|
27
|
-
for (const record of tree.split('\0').filter(Boolean)) {
|
|
28
|
-
const tab = record.indexOf('\t');
|
|
29
|
-
const [mode, type, oid] = record.slice(0, tab).split(' ');
|
|
30
|
-
base.set(record.slice(tab + 1), { mode, type, oid });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
25
|
+
// Resolve only reviewable changed baselines below; never enumerate the HEAD tree.
|
|
33
26
|
const records = text(before).split('\0');
|
|
34
27
|
const changes = [];
|
|
35
28
|
for (let i = 0; i < records.length; i++) {
|
|
@@ -42,6 +35,18 @@ export async function captureGit(cwd, options = {}) {
|
|
|
42
35
|
if (changes.length > maxFiles) throw new Error('Change count limit exceeded; narrow repository scope');
|
|
43
36
|
const known = new Set(changes.map(c => c.path));
|
|
44
37
|
if (selectedPaths?.some(p => !known.has(p))) throw new Error('Selected path is not a current change');
|
|
38
|
+
if (head) {
|
|
39
|
+
const requested = [...new Set(changes.filter(c => !isSecretPath(c.path) && !isSecretPath(c.oldPath) && (!selectedPaths || selectedPaths.includes(c.path)) && (c.rawStatus !== '??' || selectedPaths?.includes(c.path))).map(c => relativePath(c.oldPath ?? c.path)))];
|
|
40
|
+
for (const name of requested) {
|
|
41
|
+
signal?.throwIfAborted();
|
|
42
|
+
const records = text(await git(root, ['--literal-pathspecs','ls-tree','-z','--full-tree',head,'--',name], options)).split('\0').filter(Boolean);
|
|
43
|
+
for (const record of records) {
|
|
44
|
+
const m = /^(\d{6}) (blob|tree|commit) ([a-f0-9]{40}|[a-f0-9]{64})\t([\s\S]+)$/.exec(record);
|
|
45
|
+
if (!m || m[4] !== name || base.has(name)) throw new Error('Invalid changed baseline lookup');
|
|
46
|
+
base.set(name,{mode:m[1],type:m[2],oid:m[3]});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
45
50
|
const files = [];
|
|
46
51
|
for (const change of changes) {
|
|
47
52
|
signal?.throwIfAborted();
|