From 4c79d0f1c28bac2d9c949dfffd61ee4d4dcd7970 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 4 May 2019 04:17:11 -0400 Subject: [PATCH] Adds rename detection on status --- src/git/git.ts | 18 +++++++++++++++--- src/git/gitService.ts | 8 ++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/git/git.ts b/src/git/git.ts index 642ffb1..fd54913 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -978,18 +978,29 @@ export class Git { return git({ cwd: repoPath }, ...params); } - static status(repoPath: string, porcelainVersion: number = 1): Promise { + static status( + repoPath: string, + 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' } }, 'status', porcelain, '--branch', - '-u' + '-u', + `-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`, + '--' ); } - static status__file(repoPath: string, fileName: string, porcelainVersion: number = 1): Promise { + static status__file( + repoPath: string, + fileName: string, + porcelainVersion: number = 1, + { similarityThreshold }: { similarityThreshold?: number } = {} + ): Promise { const [file, root] = Git.splitPath(fileName, repoPath); const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain'; @@ -997,6 +1008,7 @@ export class Git { { cwd: root, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } }, 'status', porcelain, + `-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`, '--', file ); diff --git a/src/git/gitService.ts b/src/git/gitService.ts index ef13945..2836bd5 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -2044,7 +2044,9 @@ export class GitService implements Disposable { async getStatusForFile(repoPath: string, fileName: string): Promise { const porcelainVersion = Git.validateVersion(2, 11) ? 2 : 1; - const data = await Git.status__file(repoPath, fileName, porcelainVersion); + const data = await Git.status__file(repoPath, fileName, porcelainVersion, { + similarityThreshold: Container.config.advanced.similarityThreshold + }); const status = GitStatusParser.parse(data, repoPath, porcelainVersion); if (status === undefined || !status.files.length) return undefined; @@ -2057,7 +2059,9 @@ export class GitService implements Disposable { const porcelainVersion = Git.validateVersion(2, 11) ? 2 : 1; - const data = await Git.status(repoPath, porcelainVersion); + const data = await Git.status(repoPath, porcelainVersion, { + similarityThreshold: Container.config.advanced.similarityThreshold + }); const status = GitStatusParser.parse(data, repoPath, porcelainVersion); return status; }