From 46f7d6c1f8c64ea56cde72289072e671b41ae132 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 6 May 2019 00:47:58 -0700 Subject: [PATCH] Fixes #736 - unsupported find-renames on older git --- src/git/git.ts | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/git/git.ts b/src/git/git.ts index cdcbe0c119fa..ea988c3bd26b 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -990,14 +990,19 @@ export class Git { porcelainVersion: number = 1, { similarityThreshold }: { similarityThreshold?: number } = {} ): Promise { - const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain'; - return git( - { 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( + { cwd: repoPath, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } }, + ...params, '--' ); } @@ -1010,12 +1015,14 @@ export class Git { ): Promise { 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( { cwd: root, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } }, - 'status', - porcelain, - `-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`, + ...params, '--', file );