Skip to content

Commit c74769b

Browse files
Use spawnSync for git rev-parse to avoid shell interpolation
Co-authored-by: NullVoxPopuli <[email protected]>
1 parent 2cb2473 commit c74769b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

scripts/bench-compare.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ function run(cmd, opts = {}) {
4242
*/
4343
function resolveRef(branch) {
4444
for (const candidate of [`origin/${branch}`, branch]) {
45-
try {
46-
return execSync(`git rev-parse --verify ${candidate}`, { encoding: 'utf8' }).trim();
47-
} catch {
48-
// try next
49-
}
45+
const result = spawnSync('git', ['rev-parse', '--verify', candidate], {
46+
encoding: 'utf8',
47+
stdio: ['pipe', 'pipe', 'pipe'],
48+
});
49+
if (result.status === 0) return result.stdout.trim();
5050
}
5151
throw new Error(`Could not resolve ref for branch "${branch}". Is it fetched?`);
5252
}

0 commit comments

Comments
 (0)