Skip to content

Commit 527e853

Browse files
committed
Removes unnecessary blame interface
1 parent a2efac4 commit 527e853

File tree

6 files changed

+28
-40
lines changed

6 files changed

+28
-40
lines changed

src/codelens/codeLensProvider.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { trackableSchemes } from '../constants';
2222
import { Commands } from '../constants.commands';
2323
import type { Container } from '../container';
2424
import type { GitUri } from '../git/gitUri';
25-
import type { GitBlame, GitBlameLines } from '../git/models/blame';
25+
import type { GitBlame } from '../git/models/blame';
2626
import type { GitCommit } from '../git/models/commit';
2727
import { RemoteResourceType } from '../git/models/remoteResource';
2828
import { is, once } from '../system/function';
@@ -40,7 +40,7 @@ class GitRecentChangeCodeLens extends CodeLens {
4040
public readonly symbol: DocumentSymbol | SymbolInformation,
4141
public readonly uri: GitUri | undefined,
4242
public readonly dateFormat: string | null,
43-
private readonly blame: (() => GitBlameLines | undefined) | undefined,
43+
private readonly blame: (() => GitBlame | undefined) | undefined,
4444
public readonly blameRange: Range,
4545
public readonly isFullRange: boolean,
4646
range: Range,
@@ -50,7 +50,7 @@ class GitRecentChangeCodeLens extends CodeLens {
5050
super(range, command);
5151
}
5252

53-
getBlame(): GitBlameLines | undefined {
53+
getBlame(): GitBlame | undefined {
5454
return this.blame?.();
5555
}
5656
}
@@ -60,7 +60,7 @@ class GitAuthorsCodeLens extends CodeLens {
6060
public readonly languageId: string,
6161
public readonly symbol: DocumentSymbol | SymbolInformation,
6262
public readonly uri: GitUri | undefined,
63-
private readonly blame: () => GitBlameLines | undefined,
63+
private readonly blame: () => GitBlame | undefined,
6464
public readonly blameRange: Range,
6565
public readonly isFullRange: boolean,
6666
range: Range,
@@ -69,7 +69,7 @@ class GitAuthorsCodeLens extends CodeLens {
6969
super(range);
7070
}
7171

72-
getBlame(): GitBlameLines | undefined {
72+
getBlame(): GitBlame | undefined {
7373
return this.blame();
7474
}
7575
}
@@ -193,7 +193,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
193193
if (lenses.find(l => l.range.start.line === 0 && l.range.end.line === 0) == null) {
194194
const blameRange = documentRangeFn();
195195

196-
let blameForRangeFn: (() => GitBlameLines | undefined) | undefined = undefined;
196+
let blameForRangeFn: (() => GitBlame | undefined) | undefined = undefined;
197197
if (dirty || cfg.recentChange.enabled) {
198198
if (!dirty) {
199199
blameForRangeFn = once(() => this.container.git.getBlameRange(blame!, gitUri, blameRange));
@@ -366,7 +366,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
366366
// Anchor the CodeLens to the start of the line -- so that the range won't change with edits (otherwise the CodeLens will be removed and re-added)
367367
let startChar = 0;
368368

369-
let blameForRangeFn: (() => GitBlameLines | undefined) | undefined;
369+
let blameForRangeFn: (() => GitBlame | undefined) | undefined;
370370
if (dirty || cfg.recentChange.enabled) {
371371
if (!dirty) {
372372
blameForRangeFn = once(() => this.container.git.getBlameRange(blame!, gitUri!, blameRange));
@@ -677,7 +677,7 @@ function applyRevealCommitInViewCommand<T extends GitRecentChangeCodeLens | GitA
677677
function applyShowCommitsInViewCommand<T extends GitRecentChangeCodeLens | GitAuthorsCodeLens>(
678678
title: string,
679679
lens: T,
680-
blame: GitBlameLines,
680+
blame: GitBlame,
681681
commit?: GitCommit,
682682
): T {
683683
let refs;

src/env/node/git/localGitProvider.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import type {
6161
} from '../../../git/gitProvider';
6262
import { GitUri, isGitUri } from '../../../git/gitUri';
6363
import { encodeGitLensRevisionUriAuthority } from '../../../git/gitUri.authority';
64-
import type { GitBlame, GitBlameAuthor, GitBlameLine, GitBlameLines } from '../../../git/models/blame';
64+
import type { GitBlame, GitBlameAuthor, GitBlameLine } from '../../../git/models/blame';
6565
import type { BranchSortOptions } from '../../../git/models/branch';
6666
import {
6767
getBranchId,
@@ -2095,27 +2095,27 @@ export class LocalGitProvider implements GitProvider, Disposable {
20952095
}
20962096

20972097
@log()
2098-
async getBlameForRange(uri: GitUri, range: Range): Promise<GitBlameLines | undefined> {
2098+
async getBlameForRange(uri: GitUri, range: Range): Promise<GitBlame | undefined> {
20992099
const blame = await this.getBlame(uri);
21002100
if (blame == null) return undefined;
21012101

21022102
return this.getBlameRange(blame, uri, range);
21032103
}
21042104

21052105
@log<LocalGitProvider['getBlameForRangeContents']>({ args: { 2: '<contents>' } })
2106-
async getBlameForRangeContents(uri: GitUri, range: Range, contents: string): Promise<GitBlameLines | undefined> {
2106+
async getBlameForRangeContents(uri: GitUri, range: Range, contents: string): Promise<GitBlame | undefined> {
21072107
const blame = await this.getBlameContents(uri, contents);
21082108
if (blame == null) return undefined;
21092109

21102110
return this.getBlameRange(blame, uri, range);
21112111
}
21122112

21132113
@log<LocalGitProvider['getBlameRange']>({ args: { 0: '<blame>' } })
2114-
getBlameRange(blame: GitBlame, uri: GitUri, range: Range): GitBlameLines | undefined {
2115-
if (blame.lines.length === 0) return { allLines: blame.lines, ...blame };
2114+
getBlameRange(blame: GitBlame, uri: GitUri, range: Range): GitBlame | undefined {
2115+
if (blame.lines.length === 0) return blame;
21162116

21172117
if (range.start.line === 0 && range.end.line === blame.lines.length - 1) {
2118-
return { allLines: blame.lines, ...blame };
2118+
return blame;
21192119
}
21202120

21212121
const lines = blame.lines.slice(range.start.line, range.end.line + 1);
@@ -2154,7 +2154,6 @@ export class LocalGitProvider implements GitProvider, Disposable {
21542154
authors: sortedAuthors,
21552155
commits: commits,
21562156
lines: lines,
2157-
allLines: blame.lines,
21582157
};
21592158
}
21602159

src/git/gitProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { GitConfigKeys } from '../constants';
55
import type { SearchQuery } from '../constants.search';
66
import type { Features } from '../features';
77
import type { GitUri } from './gitUri';
8-
import type { GitBlame, GitBlameLine, GitBlameLines } from './models/blame';
8+
import type { GitBlame, GitBlameLine } from './models/blame';
99
import type { BranchSortOptions, GitBranch } from './models/branch';
1010
import type { GitCommit } from './models/commit';
1111
import type { GitContributor, GitContributorStats } from './models/contributor';
@@ -535,9 +535,9 @@ export interface GitProvider extends GitProviderRepository, Disposable {
535535
contents: string,
536536
options?: { forceSingleLine?: boolean },
537537
): Promise<GitBlameLine | undefined>;
538-
getBlameForRange(uri: GitUri, range: Range): Promise<GitBlameLines | undefined>;
539-
getBlameForRangeContents(uri: GitUri, range: Range, contents: string): Promise<GitBlameLines | undefined>;
540-
getBlameRange(blame: GitBlame, uri: GitUri, range: Range): GitBlameLines | undefined;
538+
getBlameForRange(uri: GitUri, range: Range): Promise<GitBlame | undefined>;
539+
getBlameForRangeContents(uri: GitUri, range: Range, contents: string): Promise<GitBlame | undefined>;
540+
getBlameRange(blame: GitBlame, uri: GitUri, range: Range): GitBlame | undefined;
541541
/**
542542
* Returns a file diff between two commits
543543
* @param uri Uri of the file to diff

src/git/gitProviderService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import type {
6060
ScmRepository,
6161
} from './gitProvider';
6262
import type { GitUri } from './gitUri';
63-
import type { GitBlame, GitBlameLine, GitBlameLines } from './models/blame';
63+
import type { GitBlame, GitBlameLine } from './models/blame';
6464
import type { BranchSortOptions, GitBranch } from './models/branch';
6565
import { GitCommit, GitCommitIdentity } from './models/commit';
6666
import { deletedOrMissing, uncommitted, uncommittedStaged } from './models/constants';
@@ -1625,19 +1625,19 @@ export class GitProviderService implements Disposable {
16251625
}
16261626

16271627
@log()
1628-
async getBlameForRange(uri: GitUri, range: Range): Promise<GitBlameLines | undefined> {
1628+
async getBlameForRange(uri: GitUri, range: Range): Promise<GitBlame | undefined> {
16291629
const { provider } = this.getProvider(uri);
16301630
return provider.getBlameForRange(uri, range);
16311631
}
16321632

16331633
@log<GitProviderService['getBlameForRangeContents']>({ args: { 2: '<contents>' } })
1634-
async getBlameForRangeContents(uri: GitUri, range: Range, contents: string): Promise<GitBlameLines | undefined> {
1634+
async getBlameForRangeContents(uri: GitUri, range: Range, contents: string): Promise<GitBlame | undefined> {
16351635
const { provider } = this.getProvider(uri);
16361636
return provider.getBlameForRangeContents(uri, range, contents);
16371637
}
16381638

16391639
@log<GitProviderService['getBlameRange']>({ args: { 0: '<blame>' } })
1640-
getBlameRange(blame: GitBlame, uri: GitUri, range: Range): GitBlameLines | undefined {
1640+
getBlameRange(blame: GitBlame, uri: GitUri, range: Range): GitBlame | undefined {
16411641
const { provider } = this.getProvider(uri);
16421642
return provider.getBlameRange(blame, uri, range);
16431643
}

src/git/models/blame.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,3 @@ export interface GitBlameLine {
1717
readonly commit: GitCommit;
1818
readonly line: GitCommitLine;
1919
}
20-
21-
export interface GitBlameLines extends GitBlame {
22-
readonly allLines: GitCommitLine[];
23-
}
24-
25-
export interface GitBlameCommitLines {
26-
readonly author: GitBlameAuthor;
27-
readonly commit: GitCommit;
28-
readonly lines: GitCommitLine[];
29-
}

src/plus/integrations/providers/github/githubGitProvider.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import type {
4141
} from '../../../../git/gitProvider';
4242
import { GitUri } from '../../../../git/gitUri';
4343
import { decodeRemoteHubAuthority } from '../../../../git/gitUri.authority';
44-
import type { GitBlame, GitBlameAuthor, GitBlameLine, GitBlameLines } from '../../../../git/models/blame';
44+
import type { GitBlame, GitBlameAuthor, GitBlameLine } from '../../../../git/models/blame';
4545
import type { BranchSortOptions } from '../../../../git/models/branch';
4646
import { getBranchId, getBranchNameWithoutRemote, GitBranch, sortBranches } from '../../../../git/models/branch';
4747
import type { GitCommitLine, GitStashCommit } from '../../../../git/models/commit';
@@ -820,27 +820,27 @@ export class GitHubGitProvider implements GitProvider, Disposable {
820820
}
821821

822822
@log()
823-
async getBlameForRange(uri: GitUri, range: Range): Promise<GitBlameLines | undefined> {
823+
async getBlameForRange(uri: GitUri, range: Range): Promise<GitBlame | undefined> {
824824
const blame = await this.getBlame(uri);
825825
if (blame == null) return undefined;
826826

827827
return this.getBlameRange(blame, uri, range);
828828
}
829829

830830
@log<GitHubGitProvider['getBlameForRangeContents']>({ args: { 2: '<contents>' } })
831-
async getBlameForRangeContents(uri: GitUri, range: Range, contents: string): Promise<GitBlameLines | undefined> {
831+
async getBlameForRangeContents(uri: GitUri, range: Range, contents: string): Promise<GitBlame | undefined> {
832832
const blame = await this.getBlameContents(uri, contents);
833833
if (blame == null) return undefined;
834834

835835
return this.getBlameRange(blame, uri, range);
836836
}
837837

838838
@log<GitHubGitProvider['getBlameRange']>({ args: { 0: '<blame>' } })
839-
getBlameRange(blame: GitBlame, uri: GitUri, range: Range): GitBlameLines | undefined {
840-
if (blame.lines.length === 0) return { allLines: blame.lines, ...blame };
839+
getBlameRange(blame: GitBlame, uri: GitUri, range: Range): GitBlame | undefined {
840+
if (blame.lines.length === 0) return blame;
841841

842842
if (range.start.line === 0 && range.end.line === blame.lines.length - 1) {
843-
return { allLines: blame.lines, ...blame };
843+
return blame;
844844
}
845845

846846
const lines = blame.lines.slice(range.start.line, range.end.line + 1);
@@ -879,7 +879,6 @@ export class GitHubGitProvider implements GitProvider, Disposable {
879879
authors: sortedAuthors,
880880
commits: commits,
881881
lines: lines,
882-
allLines: blame.lines,
883882
};
884883
}
885884

0 commit comments

Comments
 (0)