Quellcode durchsuchen

Adds rename detection on status

main
Eric Amodio vor 5 Jahren
Ursprung
Commit
4c79d0f1c2
2 geänderte Dateien mit 21 neuen und 5 gelöschten Zeilen
  1. +15
    -3
      src/git/git.ts
  2. +6
    -2
      src/git/gitService.ts

+ 15
- 3
src/git/git.ts Datei anzeigen

@ -978,18 +978,29 @@ export class Git {
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';
return git<string>(
{ 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<string> {
static status__file(
repoPath: string,
fileName: string,
porcelainVersion: number = 1,
{ similarityThreshold }: { similarityThreshold?: number } = {}
): Promise<string> {
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
);

+ 6
- 2
src/git/gitService.ts Datei anzeigen

@ -2044,7 +2044,9 @@ export class GitService implements Disposable {
async getStatusForFile(repoPath: string, fileName: string): Promise<GitStatusFile | undefined> {
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;
}

Laden…
Abbrechen
Speichern