fix(core): Wrap head + base arguments in quotes in execSyn (#5240)

On windows caret symbols are removed from command line args unless wrapped in double quotes, causing an error in this case.

Closes #4828.
This commit is contained in:
Craigory V Coppola 2021-04-13 14:39:41 -05:00 committed by GitHub
parent 9180e9094c
commit 4b61d44615
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,19 +45,21 @@ function getUntrackedFiles(): string[] {
function getFilesUsingBaseAndHead(base: string, head: string): string[] {
let mergeBase;
try {
mergeBase = execSync(`git merge-base ${base} ${head}`, {
mergeBase = execSync(`git merge-base "${base}" "${head}"`, {
maxBuffer: TEN_MEGABYTES,
})
.toString()
.trim();
} catch {
mergeBase = execSync(`git merge-base --fork-point ${base} ${head}`, {
mergeBase = execSync(`git merge-base --fork-point "${base}" "${head}"`, {
maxBuffer: TEN_MEGABYTES,
})
.toString()
.trim();
}
return parseGitOutput(`git diff --name-only --relative ${mergeBase} ${head}`);
return parseGitOutput(
`git diff --name-only --relative "${mergeBase}" "${head}"`
);
}
function parseGitOutput(command: string): string[] {