Skip to content

Commit

Permalink
Fixes #736 - unsupported find-renames on older git
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed May 6, 2019
1 parent 98e225f commit 46f7d6c
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/git/git.ts
Expand Up @@ -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,
'--'
);
}
Expand All @@ -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
);
Expand Down

0 comments on commit 46f7d6c

Please sign in to comment.