Skip to content

Commit 47a8de0

Browse files
authored
SCM Graph - add option to return only a subset of history item references (#228932)
1 parent be74c1f commit 47a8de0

File tree

9 files changed

+16
-13
lines changed

9 files changed

+16
-13
lines changed

extensions/git/src/api/git.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export interface InitOptions {
184184
export interface RefQuery {
185185
readonly contains?: string;
186186
readonly count?: number;
187-
readonly pattern?: string;
187+
readonly pattern?: string | string[];
188188
readonly sort?: 'alphabetically' | 'committerdate';
189189
}
190190

extensions/git/src/git.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,10 @@ export class Repository {
24312431
args.push('--format', '%(refname) %(objectname) %(*objectname)');
24322432

24332433
if (query.pattern) {
2434-
args.push(query.pattern.startsWith('refs/') ? query.pattern : `refs/${query.pattern}`);
2434+
const patterns = Array.isArray(query.pattern) ? query.pattern : [query.pattern];
2435+
for (const pattern of patterns) {
2436+
args.push(pattern.startsWith('refs/') ? pattern : `refs/${pattern}`);
2437+
}
24352438
}
24362439

24372440
if (query.contains) {

extensions/git/src/historyProvider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
174174
this.logger.trace(`[GitHistoryProvider][onDidRunWriteOperation] historyItemRefs: ${JSON.stringify(deltaLog)}`);
175175
}
176176

177-
async provideHistoryItemRefs(): Promise<SourceControlHistoryItemRef[]> {
178-
const refs = await this.repository.getRefs();
177+
async provideHistoryItemRefs(historyItemRefs: string[] | undefined): Promise<SourceControlHistoryItemRef[]> {
178+
const refs = await this.repository.getRefs({ pattern: historyItemRefs });
179179

180180
const branches: SourceControlHistoryItemRef[] = [];
181181
const remoteBranches: SourceControlHistoryItemRef[] = [];

src/vs/workbench/api/browser/mainThreadSCM.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ class MainThreadSCMHistoryProvider implements ISCMHistoryProvider {
199199
return this.proxy.$resolveHistoryItemRefsCommonAncestor(this.handle, historyItemRefs, CancellationToken.None);
200200
}
201201

202-
async provideHistoryItemRefs(): Promise<ISCMHistoryItemRef[] | undefined> {
203-
const historyItemRefs = await this.proxy.$provideHistoryItemRefs(this.handle, CancellationToken.None);
202+
async provideHistoryItemRefs(historyItemsRefs?: string[]): Promise<ISCMHistoryItemRef[] | undefined> {
203+
const historyItemRefs = await this.proxy.$provideHistoryItemRefs(this.handle, historyItemsRefs, CancellationToken.None);
204204
return historyItemRefs?.map(ref => ({ ...ref, icon: getIconFromIconDto(ref.icon) }));
205205
}
206206

src/vs/workbench/api/common/extHost.protocol.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2400,7 +2400,7 @@ export interface ExtHostSCMShape {
24002400
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number, preserveFocus: boolean): Promise<void>;
24012401
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Promise<[string | IMarkdownString, number] | undefined>;
24022402
$setSelectedSourceControl(selectedSourceControlHandle: number | undefined): Promise<void>;
2403-
$provideHistoryItemRefs(sourceControlHandle: number, token: CancellationToken): Promise<SCMHistoryItemRefDto[] | undefined>;
2403+
$provideHistoryItemRefs(sourceControlHandle: number, historyItemRefs: string[] | undefined, token: CancellationToken): Promise<SCMHistoryItemRefDto[] | undefined>;
24042404
$provideHistoryItems(sourceControlHandle: number, options: any, token: CancellationToken): Promise<SCMHistoryItemDto[] | undefined>;
24052405
$provideHistoryItemChanges(sourceControlHandle: number, historyItemId: string, historyItemParentId: string | undefined, token: CancellationToken): Promise<SCMHistoryItemChangeDto[] | undefined>;
24062406
$resolveHistoryItemRefsCommonAncestor(sourceControlHandle: number, historyItemRefs: string[], token: CancellationToken): Promise<string | undefined>;

src/vs/workbench/api/common/extHostSCM.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -999,11 +999,11 @@ export class ExtHostSCM implements ExtHostSCMShape {
999999
return await historyProvider?.resolveHistoryItemRefsCommonAncestor(historyItemRefs, token) ?? undefined;
10001000
}
10011001

1002-
async $provideHistoryItemRefs(sourceControlHandle: number, token: CancellationToken): Promise<SCMHistoryItemRefDto[] | undefined> {
1002+
async $provideHistoryItemRefs(sourceControlHandle: number, historyItemRefs: string[] | undefined, token: CancellationToken): Promise<SCMHistoryItemRefDto[] | undefined> {
10031003
const historyProvider = this._sourceControls.get(sourceControlHandle)?.historyProvider;
1004-
const historyItemRefs = await historyProvider?.provideHistoryItemRefs(token);
1004+
const refs = await historyProvider?.provideHistoryItemRefs(historyItemRefs, token);
10051005

1006-
return historyItemRefs?.map(ref => ({ ...ref, icon: getHistoryItemIconDto(ref.icon) })) ?? undefined;
1006+
return refs?.map(ref => ({ ...ref, icon: getHistoryItemIconDto(ref.icon) })) ?? undefined;
10071007
}
10081008

10091009
async $provideHistoryItems(sourceControlHandle: number, options: any, token: CancellationToken): Promise<SCMHistoryItemDto[] | undefined> {

src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ class SCMHistoryViewModel extends Disposable {
916916
break;
917917
default: {
918918
// Get the latest revisions for the history items references in the filer
919-
const refs = (await historyProvider.provideHistoryItemRefs() ?? [])
919+
const refs = (await historyProvider.provideHistoryItemRefs(historyItemsFilter) ?? [])
920920
.filter(ref => historyItemsFilter.some(filter => filter === ref.id));
921921

922922
if (refs.length === 0) {

src/vs/workbench/contrib/scm/common/history.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface ISCMHistoryProvider {
2121

2222
readonly historyItemRefChanges: IObservable<ISCMHistoryItemRefsChangeEvent>;
2323

24-
provideHistoryItemRefs(): Promise<ISCMHistoryItemRef[] | undefined>;
24+
provideHistoryItemRefs(historyItemsRefs?: string[]): Promise<ISCMHistoryItemRef[] | undefined>;
2525
provideHistoryItems(options: ISCMHistoryOptions): Promise<ISCMHistoryItem[] | undefined>;
2626
provideHistoryItemChanges(historyItemId: string, historyItemParentId: string | undefined): Promise<ISCMHistoryItemChange[] | undefined>;
2727
resolveHistoryItemRefsCommonAncestor(historyItemRefs: string[]): Promise<string | undefined>;

src/vscode-dts/vscode.proposed.scmHistoryProvider.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ declare module 'vscode' {
2626
*/
2727
onDidChangeHistoryItemRefs: Event<SourceControlHistoryItemRefsChangeEvent>;
2828

29-
provideHistoryItemRefs(token: CancellationToken): ProviderResult<SourceControlHistoryItemRef[]>;
29+
provideHistoryItemRefs(historyItemRefs: string[] | undefined, token: CancellationToken): ProviderResult<SourceControlHistoryItemRef[]>;
3030
provideHistoryItems(options: SourceControlHistoryOptions, token: CancellationToken): ProviderResult<SourceControlHistoryItem[]>;
3131
provideHistoryItemChanges(historyItemId: string, historyItemParentId: string | undefined, token: CancellationToken): ProviderResult<SourceControlHistoryItemChange[]>;
3232

0 commit comments

Comments
 (0)