Browse Source

Adds rename detection on status

main
Eric Amodio 5 years ago
parent
commit
4c79d0f1c2
2 changed files with 21 additions and 5 deletions
  1. +15
    -3
      src/git/git.ts
  2. +6
    -2
      src/git/gitService.ts

+ 15
- 3
src/git/git.ts View File

@ -978,18 +978,29 @@ export class Git {
return git<string>({ cwd: repoPath }, ...params); return git<string>({ cwd: repoPath }, ...params);
} }
static status(repoPath: string, porcelainVersion: number = 1): Promise<string> {
static status(
repoPath: string,
porcelainVersion: number = 1,
{ similarityThreshold }: { similarityThreshold?: number } = {}
): Promise<string> {
const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain'; const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain';
return git<string>( return git<string>(
{ cwd: repoPath, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } }, { cwd: repoPath, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } },
'status', 'status',
porcelain, porcelain,
'--branch', '--branch',
'-u'
'-u',
`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`,
'--'
); );
} }
static status__file(repoPath: string, fileName: string, porcelainVersion: number = 1): Promise<string> {
static status__file(
repoPath: string,
fileName: string,
porcelainVersion: number = 1,
{ similarityThreshold }: { similarityThreshold?: number } = {}
): Promise<string> {
const [file, root] = Git.splitPath(fileName, repoPath); const [file, root] = Git.splitPath(fileName, repoPath);
const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain'; 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' } }, { cwd: root, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } },
'status', 'status',
porcelain, porcelain,
`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`,
'--', '--',
file file
); );

+ 6
- 2
src/git/gitService.ts View File

@ -2044,7 +2044,9 @@ export class GitService implements Disposable {
async getStatusForFile(repoPath: string, fileName: string): Promise<GitStatusFile | undefined> { async getStatusForFile(repoPath: string, fileName: string): Promise<GitStatusFile | undefined> {
const porcelainVersion = Git.validateVersion(2, 11) ? 2 : 1; 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); const status = GitStatusParser.parse(data, repoPath, porcelainVersion);
if (status === undefined || !status.files.length) return undefined; 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 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); const status = GitStatusParser.parse(data, repoPath, porcelainVersion);
return status; return status;
} }

Loading…
Cancel
Save