Browse Source

Fixes #736 - unsupported find-renames on older git

main
Eric Amodio 5 years ago
parent
commit
46f7d6c1f8
1 changed files with 17 additions and 10 deletions
  1. +17
    -10
      src/git/git.ts

+ 17
- 10
src/git/git.ts View File

@ -990,14 +990,19 @@ export class Git {
porcelainVersion: number = 1,
{ similarityThreshold }: { similarityThreshold?: number } = {}
): Promise<string> {
const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain';
return git<string>(
{ cwd: repoPath, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } },
const params = [
'status',
porcelain,
porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain',
'--branch',
'-u',
`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`,
'-u'
];
if (Git.validateVersion(2, 18)) {
params.push(`--find-renames=${similarityThreshold == null ? '' : `${similarityThreshold}%`}`);
}
return git<string>(
{ cwd: repoPath, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } },
...params,
'--'
);
}
@ -1010,12 +1015,14 @@ export class Git {
): Promise<string> {
const [file, root] = Git.splitPath(fileName, repoPath);
const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain';
const params = ['status', porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain'];
if (Git.validateVersion(2, 18)) {
params.push(`--find-renames=${similarityThreshold == null ? '' : `${similarityThreshold}%`}`);
}
return git<string>(
{ cwd: root, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } },
'status',
porcelain,
`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`,
...params,
'--',
file
);

Loading…
Cancel
Save