18 lines
536 B
JavaScript
18 lines
536 B
JavaScript
export function parseGitStatusPorcelainZ(output) {
|
|
const entries = String(output ?? '').split('\0');
|
|
const paths = [];
|
|
for (let index = 0; index < entries.length; index += 1) {
|
|
const entry = entries[index];
|
|
if (!entry) continue;
|
|
if (entry.length < 4 || entry[2] !== ' ') {
|
|
throw new Error(`Invalid git status --porcelain=v1 -z entry: ${entry.slice(0, 20)}`);
|
|
}
|
|
const status = entry.slice(0, 2);
|
|
paths.push(entry.slice(3));
|
|
if (/[RC]/.test(status)) {
|
|
index += 1;
|
|
}
|
|
}
|
|
return paths;
|
|
}
|