Skip to content

Commit

Permalink
SCM - πŸ’„ API cleanup (#209339)
Browse files Browse the repository at this point in the history
* SCM - πŸ’„ API cleanup

* Fix compilation
  • Loading branch information
lszomoru authored Apr 2, 2024
1 parent fba040a commit 8d1ecd7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions extensions/git/src/historyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec

this.currentHistoryItemGroup = {
id: `refs/heads/${this.repository.HEAD.name ?? ''}`,
label: this.repository.HEAD.name ?? '',
name: this.repository.HEAD.name ?? '',
base: this.repository.HEAD.upstream ?
{
id: `refs/remotes/${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`,
label: `${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`,
name: `${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`,
} : undefined
};

Expand Down Expand Up @@ -101,8 +101,8 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
return {
id: commit.hash,
parentIds: commit.parents,
label: emojify(subject),
description: commit.authorName,
message: emojify(subject),
author: commit.authorName,
icon: new ThemeIcon('git-commit'),
timestamp: commit.authorDate?.getTime(),
statistics: commit.shortStat ?? { files: 0, insertions: 0, deletions: 0 },
Expand All @@ -119,7 +119,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
}

const allChanges = await this.repository.diffBetweenShortStat(historyItemParentId, historyItemId);
return { id: historyItemId, parentIds: [historyItemParentId], label: '', statistics: allChanges };
return { id: historyItemId, parentIds: [historyItemParentId], message: '', statistics: allChanges };
}

async provideHistoryItemChanges(historyItemId: string, historyItemParentId: string | undefined): Promise<SourceControlHistoryItemChange[]> {
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1493,15 +1493,15 @@ export type SCMRawResourceSplices = [

export interface SCMHistoryItemGroupDto {
readonly id: string;
readonly label: string;
readonly name: string;
readonly base?: Omit<SCMHistoryItemGroupDto, 'base'>;
}

export interface SCMHistoryItemDto {
readonly id: string;
readonly parentIds: string[];
readonly label: string;
readonly description?: string;
readonly message: string;
readonly author?: string;
readonly icon?: UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon;
readonly timestamp?: number;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/scm/browser/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class SCMActiveRepositoryContextKeyController implements IWorkbenchContri

private updateContextKeys(repository: ISCMRepository | undefined): void {
this.activeRepositoryNameContextKey.set(repository?.provider.name ?? '');
this.activeRepositoryBranchNameContextKey.set(repository?.provider.historyProvider?.currentHistoryItemGroup?.label ?? '');
this.activeRepositoryBranchNameContextKey.set(repository?.provider.historyProvider?.currentHistoryItemGroup?.name ?? '');
}

dispose(): void {
Expand Down
24 changes: 12 additions & 12 deletions src/vs/workbench/contrib/scm/browser/scmViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,8 @@ class HistoryItemActionRunner extends ActionRunner {
args.push({
id: context.id,
parentIds: context.parentIds,
label: context.label,
description: context.description,
message: context.message,
author: context.author,
icon: context.icon,
timestamp: context.timestamp,
statistics: context.statistics,
Expand Down Expand Up @@ -940,7 +940,7 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
}

const [matches, descriptionMatches] = this.processMatches(historyItem, node.filterData);
templateData.label.setLabel(historyItem.label, historyItem.description, { matches, descriptionMatches });
templateData.label.setLabel(historyItem.message, historyItem.author, { matches, descriptionMatches });

templateData.actionBar.clear();
templateData.actionBar.context = historyItem;
Expand All @@ -964,8 +964,8 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
}

return [
historyItem.label === filterData.label ? createMatches(filterData.score) : undefined,
historyItem.description === filterData.label ? createMatches(filterData.score) : undefined
historyItem.message === filterData.label ? createMatches(filterData.score) : undefined,
historyItem.author === filterData.label ? createMatches(filterData.score) : undefined
];
}

Expand Down Expand Up @@ -1318,7 +1318,7 @@ export class SCMTreeKeyboardNavigationLabelProvider implements ICompressibleKeyb
// For a history item we want to match both the message and
// the author. A match in the message takes precedence over
// a match in the author.
return [element.label, element.description];
return [element.message, element.author];
} else if (isSCMViewSeparator(element)) {
return element.label;
} else {
Expand Down Expand Up @@ -1418,7 +1418,7 @@ export class SCMAccessibilityProvider implements IListAccessibilityProvider<Tree
} else if (isSCMHistoryItemGroupTreeElement(element)) {
return element.ariaLabel ?? `${element.label.trim()}${element.description ? `, ${element.description}` : ''}`;
} else if (isSCMHistoryItemTreeElement(element)) {
return `${stripIcons(element.label).trim()}${element.description ? `, ${element.description}` : ''}`;
return `${stripIcons(element.message).trim()}${element.author ? `, ${element.author}` : ''}`;
} else if (isSCMHistoryItemChangeTreeElement(element)) {
const result = [basename(element.uri)];
const path = this.labelService.getUriLabel(dirname(element.uri), { relative: true, noPrefix: true });
Expand Down Expand Up @@ -3623,8 +3623,8 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
// Only show "Incoming" node if there is a base branch
incomingHistoryItemGroup = currentHistoryItemGroup.base ? {
id: currentHistoryItemGroup.base.id,
label: currentHistoryItemGroup.base.label,
ariaLabel: localize('incomingChangesAriaLabel', "Incoming changes from {0}", currentHistoryItemGroup.base.label),
label: currentHistoryItemGroup.base.name,
ariaLabel: localize('incomingChangesAriaLabel', "Incoming changes from {0}", currentHistoryItemGroup.base.name),
icon: Codicon.arrowCircleDown,
direction: 'incoming',
ancestor: ancestor.id,
Expand All @@ -3635,8 +3635,8 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement

outgoingHistoryItemGroup = {
id: currentHistoryItemGroup.id,
label: currentHistoryItemGroup.label,
ariaLabel: localize('outgoingChangesAriaLabel', "Outgoing changes to {0}", currentHistoryItemGroup.label),
label: currentHistoryItemGroup.name,
ariaLabel: localize('outgoingChangesAriaLabel', "Outgoing changes to {0}", currentHistoryItemGroup.name),
icon: Codicon.arrowCircleUp,
direction: 'outgoing',
ancestor: ancestor.id,
Expand Down Expand Up @@ -3702,7 +3702,7 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
children.push({
...historyItemsElement[0],
icon: historyItemsElement[0].icon ?? Codicon.files,
label: localize('allChanges', "All Changes"),
message: localize('allChanges', "All Changes"),
historyItemGroup: element,
type: 'allChanges'
} satisfies SCMHistoryItemTreeElement);
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/scm/common/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface ISCMHistoryOptions {

export interface ISCMHistoryItemGroup {
readonly id: string;
readonly label: string;
readonly name: string;
readonly base?: Omit<ISCMHistoryItemGroup, 'base'>;
}

Expand All @@ -69,8 +69,8 @@ export interface ISCMHistoryItemStatistics {
export interface ISCMHistoryItem {
readonly id: string;
readonly parentIds: string[];
readonly label: string;
readonly description?: string;
readonly message: string;
readonly author?: string;
readonly icon?: URI | { light: URI; dark: URI } | ThemeIcon;
readonly timestamp?: number;
readonly statistics?: ISCMHistoryItemStatistics;
Expand Down
8 changes: 4 additions & 4 deletions src/vscode-dts/vscode.proposed.scmHistoryProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ declare module 'vscode' {

export interface SourceControlHistoryItemGroup {
readonly id: string;
readonly label: string;
readonly name: string;
readonly base?: Omit<SourceControlRemoteHistoryItemGroup, 'base'>;
}

export interface SourceControlRemoteHistoryItemGroup {
readonly id: string;
readonly label: string;
readonly name: string;
}

export interface SourceControlHistoryItemStatistics {
Expand All @@ -56,8 +56,8 @@ declare module 'vscode' {
export interface SourceControlHistoryItem {
readonly id: string;
readonly parentIds: string[];
readonly label: string;
readonly description?: string;
readonly message: string;
readonly author?: string;
readonly icon?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
readonly timestamp?: number;
readonly statistics?: SourceControlHistoryItemStatistics;
Expand Down

0 comments on commit 8d1ecd7

Please sign in to comment.