Browse Source

Fixes #670 - Configure similarity index for diffs

main
x13machine 5 years ago
committed by Eric Amodio
parent
commit
2b1777fbaf
6 changed files with 24 additions and 5 deletions
  1. +6
    -0
      package.json
  2. +1
    -0
      src/config.ts
  3. +8
    -2
      src/git/git.ts
  4. +1
    -1
      src/git/gitService.ts
  5. +4
    -1
      src/views/nodes/resultsFilesNode.ts
  6. +4
    -1
      src/views/nodes/statusFilesNode.ts

+ 6
- 0
package.json View File

@ -1293,6 +1293,12 @@
"markdownDescription": "Specifies whether to show avatar images instead of commit (or status) icons in the _Compare_ view",
"scope": "window"
},
"gitlens.views.compare.findRenames": {
"type": "number",
"default": 50,
"markdownDescription": "Specifies the threshold for the rename similarity index.",
"scope": "window"
},
"gitlens.views.compare.enabled": {
"type": "boolean",
"default": true,

+ 1
- 0
src/config.ts View File

@ -244,6 +244,7 @@ export interface CompareViewConfig {
avatars: boolean;
enabled: boolean;
files: ViewsFilesConfig;
findRenames: number;
location: ViewLocation;
}

+ 8
- 2
src/git/git.ts View File

@ -525,8 +525,14 @@ export class Git {
}
}
static diff_nameStatus(repoPath: string, ref1?: string, ref2?: string, options: { filter?: string } = {}) {
const params = ['diff', '--name-status', '-M', '--no-ext-diff'];
static diff_nameStatus(
repoPath: string,
ref1?: string,
ref2?: string,
options: { filter?: string; findRenames?: number } = {}
) {
const renameParameter = options.findRenames == null ? '-M' : `-M${options.findRenames}%`;
const params = ['diff', '--name-status', renameParameter, '--no-ext-diff'];
if (options && options.filter) {
params.push(`--diff-filter=${options.filter}`);
}

+ 1
- 1
src/git/gitService.ts View File

@ -1309,7 +1309,7 @@ export class GitService implements Disposable {
repoPath: string,
ref1?: string,
ref2?: string,
options: { filter?: string } = {}
options: { filter?: string; findRenames?: number } = {}
): Promise<GitFile[] | undefined> {
try {
const data = await Git.diff_nameStatus(repoPath, ref1, ref2, options);

+ 4
- 1
src/views/nodes/resultsFilesNode.ts View File

@ -82,7 +82,10 @@ export class ResultsFilesNode extends ViewNode {
}
private async getFilesQueryResultsCore(): Promise<FilesQueryResults> {
const diff = await Container.git.getDiffStatus(this.uri.repoPath!, this._ref1, this._ref2);
const diff = await Container.git.getDiffStatus(this.uri.repoPath!, this._ref1, this._ref2, {
findRenames: Container.config.views.compare.findRenames
});
return {
label: `${Strings.pluralize('file', diff !== undefined ? diff.length : 0, { zero: 'No' })} changed`,
diff: diff

+ 4
- 1
src/views/nodes/statusFilesNode.ts View File

@ -119,7 +119,10 @@ export class StatusFilesNode extends ViewNode {
if (this.status.upstream !== undefined && this.status.state.ahead > 0) {
if (files > 0) {
const aheadFiles = await Container.git.getDiffStatus(this.repoPath, `${this.status.upstream}...`);
const aheadFiles = await Container.git.getDiffStatus(this.repoPath, `${this.status.upstream}...`, undefined, {
findRenames: Container.config.views.compare.findRenames
});
if (aheadFiles !== undefined) {
const uniques = new Set();
for (const f of this.status.files) {

Loading…
Cancel
Save