Skip to content

Commit

Permalink
Splits git utils into webview safe vs vscode only
Browse files Browse the repository at this point in the history
Moves paused operation status strings into utils
  • Loading branch information
eamodio committed Jan 8, 2025
1 parent 1bb9220 commit 175807c
Show file tree
Hide file tree
Showing 29 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/autolinks/autolinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { IntegrationId } from '../constants.integrations';
import { IssueIntegrationId } from '../constants.integrations';
import type { Container } from '../container';
import type { GitRemote } from '../git/models/remote';
import { getIssueOrPullRequestHtmlIcon, getIssueOrPullRequestMarkdownIcon } from '../git/utils/icons';
import { getIssueOrPullRequestHtmlIcon, getIssueOrPullRequestMarkdownIcon } from '../git/utils/vscode/icons';
import type { HostingIntegration, IssueIntegration } from '../plus/integrations/integration';
import { fromNow } from '../system/date';
import { debug } from '../system/decorators/log';
Expand Down
4 changes: 2 additions & 2 deletions src/commands/quickCommand.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import type { WorktreeQuickPickItem } from '../git/models/worktree.quickpick';
import { createWorktreeQuickPickItem } from '../git/models/worktree.quickpick';
import { getWorktreesByBranch } from '../git/models/worktree.utils';
import { remoteUrlRegex } from '../git/parsers/remoteParser';
import type { BranchSortOptions, TagSortOptions } from '../git/utils/sorting';
import { sortBranches, sortContributors, sortTags, sortWorktrees } from '../git/utils/sorting';
import type { BranchSortOptions, TagSortOptions } from '../git/utils/vscode/sorting';
import { sortBranches, sortContributors, sortTags, sortWorktrees } from '../git/utils/vscode/sorting';
import { getApplicablePromo } from '../plus/gk/account/promos';
import { isSubscriptionPaidPlan, isSubscriptionPreviewTrialExpired } from '../plus/gk/account/subscription';
import type { LaunchpadCommandArgs } from '../plus/launchpad/launchpad';
Expand Down
6 changes: 3 additions & 3 deletions src/env/node/git/localGitProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ import { parseGitWorktrees } from '../../../git/parsers/worktreeParser';
import { getRemoteProviderMatcher, loadRemoteProviders } from '../../../git/remotes/remoteProviders';
import type { GitSearch, GitSearchResultData, GitSearchResults } from '../../../git/search';
import { getGitArgsFromSearchQuery, getSearchQueryComparisonKey } from '../../../git/search';
import { getRemoteIconUri } from '../../../git/utils/icons';
import type { BranchSortOptions, TagSortOptions } from '../../../git/utils/sorting';
import { sortBranches, sortContributors, sortTags } from '../../../git/utils/sorting';
import { getRemoteIconUri } from '../../../git/utils/vscode/icons';
import type { BranchSortOptions, TagSortOptions } from '../../../git/utils/vscode/sorting';
import { sortBranches, sortContributors, sortTags } from '../../../git/utils/vscode/sorting';
import {
showBlameInvalidIgnoreRevsFileWarningMessage,
showGenericErrorMessage,
Expand Down
2 changes: 1 addition & 1 deletion src/git/formatters/commitFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { getHighlanderProviders } from '../models/remote';
import { uncommitted, uncommittedStaged } from '../models/revision';
import { isUncommittedStaged, shortenRevision } from '../models/revision.utils';
import type { RemoteProvider } from '../remotes/remoteProvider';
import { getIssueOrPullRequestMarkdownIcon } from '../utils/icons';
import { getIssueOrPullRequestMarkdownIcon } from '../utils/vscode/icons';
import type { FormatOptions, RequiredTokenOptions } from './formatter';
import { Formatter } from './formatter';

Expand Down
2 changes: 1 addition & 1 deletion src/git/gitProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type { GitTreeEntry } from './models/tree';
import type { GitUser } from './models/user';
import type { GitWorktree } from './models/worktree';
import type { GitSearch } from './search';
import type { BranchSortOptions, TagSortOptions } from './utils/sorting';
import type { BranchSortOptions, TagSortOptions } from './utils/vscode/sorting';

export type GitCaches =
| 'branches'
Expand Down
4 changes: 2 additions & 2 deletions src/git/gitProviderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ import type { GitUser } from './models/user';
import type { GitWorktree } from './models/worktree';
import type { RemoteProvider } from './remotes/remoteProvider';
import type { GitSearch } from './search';
import type { BranchSortOptions, TagSortOptions } from './utils/sorting';
import { sortRepositories } from './utils/sorting';
import type { BranchSortOptions, TagSortOptions } from './utils/vscode/sorting';
import { sortRepositories } from './utils/vscode/sorting';

const emptyArray = Object.freeze([]) as unknown as any[];
const emptyDisposable = Object.freeze({
Expand Down
24 changes: 0 additions & 24 deletions src/git/models/pausedOperationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,3 @@ export interface GitRevertStatus {

mergeBase?: never;
}

export const statusStringsByType = {
'cherry-pick': {
label: 'Cherry picking',
conflicts: 'Resolve conflicts to continue cherry picking',
directionality: 'into',
},
merge: {
label: 'Merging',
conflicts: 'Resolve conflicts to continue merging',
directionality: 'into',
},
rebase: {
label: 'Rebasing',
conflicts: 'Resolve conflicts to continue rebasing',
directionality: 'onto',
pending: 'Pending rebase of',
},
revert: {
label: 'Reverting',
conflicts: 'Resolve conflicts to continue reverting',
directionality: 'in',
},
} as const;
2 changes: 1 addition & 1 deletion src/git/models/worktree.quickpick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { pad } from '../../system/string';
import { getBranchIconPath } from '../utils/icons';
import { getBranchIconPath } from '../utils/vscode/icons';
import { shortenRevision } from './revision.utils';
import type { GitStatus } from './status';
import type { GitWorktree } from './worktree';
Expand Down
2 changes: 1 addition & 1 deletion src/git/remotes/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { escapeMarkdown, unescapeMarkdown } from '../../system/markdown';
import { equalsIgnoreCase } from '../../system/string';
import type { Repository } from '../models/repository';
import { isSha } from '../models/revision.utils';
import { getIssueOrPullRequestMarkdownIcon } from '../utils/icons';
import { getIssueOrPullRequestMarkdownIcon } from '../utils/vscode/icons';
import type { RemoteProviderId } from './remoteProvider';
import { RemoteProvider } from './remoteProvider';

Expand Down
2 changes: 1 addition & 1 deletion src/git/remotes/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { escapeMarkdown, unescapeMarkdown } from '../../system/markdown';
import { equalsIgnoreCase } from '../../system/string';
import type { Repository } from '../models/repository';
import { isSha } from '../models/revision.utils';
import { getIssueOrPullRequestMarkdownIcon } from '../utils/icons';
import { getIssueOrPullRequestMarkdownIcon } from '../utils/vscode/icons';
import type { RemoteProviderId } from './remoteProvider';
import { RemoteProvider } from './remoteProvider';

Expand Down
23 changes: 23 additions & 0 deletions src/git/utils/pausedOperationStatus.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const pausedOperationStatusStringsByType = {
'cherry-pick': {
label: 'Cherry picking',
conflicts: 'Resolve conflicts to continue cherry picking',
directionality: 'into',
},
merge: {
label: 'Merging',
conflicts: 'Resolve conflicts to continue merging',
directionality: 'into',
},
rebase: {
label: 'Rebasing',
conflicts: 'Resolve conflicts to continue rebasing',
directionality: 'onto',
pending: 'Pending rebase of',
},
revert: {
label: 'Reverting',
conflicts: 'Resolve conflicts to continue reverting',
directionality: 'in',
},
} as const;
22 changes: 11 additions & 11 deletions src/git/utils/icons.ts → src/git/utils/vscode/icons.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { ColorTheme } from 'vscode';
import { ColorThemeKind, ThemeColor, ThemeIcon, Uri, window } from 'vscode';
import type { IconPath } from '../../@types/vscode.iconpath';
import type { Colors } from '../../constants.colors';
import type { Container } from '../../container';
import { isLightTheme } from '../../system/vscode/utils';
import { getIconPathUris } from '../../system/vscode/vscode';
import type { GitBranch } from '../models/branch';
import type { IssueOrPullRequest } from '../models/issue';
import type { GitRemote } from '../models/remote';
import { getRemoteThemeIconString } from '../models/remote';
import type { Repository } from '../models/repository';
import type { GitStatus } from '../models/status';
import type { IconPath } from '../../../@types/vscode.iconpath';
import type { Colors } from '../../../constants.colors';
import type { Container } from '../../../container';
import { isLightTheme } from '../../../system/vscode/utils';
import { getIconPathUris } from '../../../system/vscode/vscode';
import type { GitBranch } from '../../models/branch';
import type { IssueOrPullRequest } from '../../models/issue';
import type { GitRemote } from '../../models/remote';
import { getRemoteThemeIconString } from '../../models/remote';
import type { Repository } from '../../models/repository';
import type { GitStatus } from '../../models/status';

export function getBranchIconPath(container: Container, branch: GitBranch | undefined): IconPath {
switch (branch?.status) {
Expand Down
24 changes: 12 additions & 12 deletions src/git/utils/sorting.ts → src/git/utils/vscode/sorting.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { BranchSorting, ContributorSorting, RepositoriesSorting, TagSorting } from '../../config';
import { sortCompare } from '../../system/string';
import { configuration } from '../../system/vscode/configuration';
import type { GitBranch } from '../models/branch';
import type { GitContributor } from '../models/contributor';
import { isContributor } from '../models/contributor';
import type { ContributorQuickPickItem } from '../models/contributor.quickpick';
import type { Repository } from '../models/repository';
import type { GitTag } from '../models/tag';
import type { GitWorktree } from '../models/worktree';
import { isWorktree } from '../models/worktree';
import type { WorktreeQuickPickItem } from '../models/worktree.quickpick';
import type { BranchSorting, ContributorSorting, RepositoriesSorting, TagSorting } from '../../../config';
import { sortCompare } from '../../../system/string';
import { configuration } from '../../../system/vscode/configuration';
import type { GitBranch } from '../../models/branch';
import type { GitContributor } from '../../models/contributor';
import { isContributor } from '../../models/contributor';
import type { ContributorQuickPickItem } from '../../models/contributor.quickpick';
import type { Repository } from '../../models/repository';
import type { GitTag } from '../../models/tag';
import type { GitWorktree } from '../../models/worktree';
import { isWorktree } from '../../models/worktree';
import type { WorktreeQuickPickItem } from '../../models/worktree.quickpick';

export interface BranchSortOptions {
current?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions src/plus/integrations/providers/github/githubGitProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ import type { GitWorktree } from '../../../../git/models/worktree';
import { getRemoteProviderMatcher, loadRemoteProviders } from '../../../../git/remotes/remoteProviders';
import type { GitSearch, GitSearchResultData, GitSearchResults } from '../../../../git/search';
import { getSearchQueryComparisonKey, parseSearchQuery } from '../../../../git/search';
import { getRemoteIconUri } from '../../../../git/utils/icons';
import type { BranchSortOptions, TagSortOptions } from '../../../../git/utils/sorting';
import { sortBranches, sortTags } from '../../../../git/utils/sorting';
import { getRemoteIconUri } from '../../../../git/utils/vscode/icons';
import type { BranchSortOptions, TagSortOptions } from '../../../../git/utils/vscode/sorting';
import { sortBranches, sortTags } from '../../../../git/utils/vscode/sorting';
import { gate } from '../../../../system/decorators/gate';
import { debug, log } from '../../../../system/decorators/log';
import { filterMap, first, last, map, some, union } from '../../../../system/iterable';
Expand Down
2 changes: 1 addition & 1 deletion src/quickpicks/contributorsPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { GitContributor } from '../git/models/contributor';
import type { ContributorQuickPickItem } from '../git/models/contributor.quickpick';
import { createContributorQuickPickItem } from '../git/models/contributor.quickpick';
import type { Repository } from '../git/models/repository';
import { sortContributors } from '../git/utils/sorting';
import { sortContributors } from '../git/utils/vscode/sorting';
import { debounce } from '../system/function';
import { defer } from '../system/promise';
import { pad, truncate } from '../system/string';
Expand Down
2 changes: 1 addition & 1 deletion src/quickpicks/items/gitWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getRemoteUpstreamDescription } from '../../git/models/remote';
import type { Repository } from '../../git/models/repository';
import { isRevisionRange, shortenRevision } from '../../git/models/revision.utils';
import type { GitTag } from '../../git/models/tag';
import { getBranchIconPath, getWorktreeBranchIconPath } from '../../git/utils/icons';
import { getBranchIconPath, getWorktreeBranchIconPath } from '../../git/utils/vscode/icons';
import { fromNow } from '../../system/date';
import { pad } from '../../system/string';
import { configuration } from '../../system/vscode/configuration';
Expand Down
2 changes: 1 addition & 1 deletion src/quickpicks/referencePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { GitBranch } from '../git/models/branch';
import type { GitReference } from '../git/models/reference';
import { isBranchReference, isRevisionReference, isTagReference } from '../git/models/reference.utils';
import type { GitTag } from '../git/models/tag';
import type { BranchSortOptions, TagSortOptions } from '../git/utils/sorting';
import type { BranchSortOptions, TagSortOptions } from '../git/utils/vscode/sorting';
import type { KeyboardScope } from '../system/vscode/keyboard';
import { getQuickPickIgnoreFocusOut } from '../system/vscode/utils';
import type { BranchQuickPickItem, RefQuickPickItem, TagQuickPickItem } from './items/gitWizard';
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/autolinkedItemNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'v
import type { Autolink } from '../../autolinks';
import { GitUri } from '../../git/gitUri';
import type { IssueOrPullRequest } from '../../git/models/issue';
import { getIssueOrPullRequestMarkdownIcon, getIssueOrPullRequestThemeIcon } from '../../git/utils/icons';
import { getIssueOrPullRequestMarkdownIcon, getIssueOrPullRequestThemeIcon } from '../../git/utils/vscode/icons';
import { fromNow } from '../../system/date';
import { isPromise } from '../../system/promise';
import type { ViewsWithCommits } from '../viewBase';
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/branchNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { getHighlanderProviders } from '../../git/models/remote';
import { Repository } from '../../git/models/repository';
import type { GitUser } from '../../git/models/user';
import type { GitWorktree } from '../../git/models/worktree';
import { getBranchIconPath, getRemoteIconPath, getWorktreeBranchIconPath } from '../../git/utils/icons';
import { getBranchIconPath, getRemoteIconPath, getWorktreeBranchIconPath } from '../../git/utils/vscode/icons';
import { fromNow } from '../../system/date';
import { gate } from '../../system/decorators/gate';
import { log } from '../../system/decorators/log';
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/contributorsNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import type { GitUri } from '../../git/gitUri';
import type { GitContributor } from '../../git/models/contributor';
import type { Repository } from '../../git/models/repository';
import { sortContributors } from '../../git/utils/sorting';
import { sortContributors } from '../../git/utils/vscode/sorting';
import { debug } from '../../system/decorators/log';
import { configuration } from '../../system/vscode/configuration';
import type { ViewsWithContributorsNode } from '../viewBase';
Expand Down
10 changes: 5 additions & 5 deletions src/views/nodes/pausedOperationStatusNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type { Colors } from '../../constants.colors';
import { GitUri } from '../../git/gitUri';
import type { GitBranch } from '../../git/models/branch';
import type { GitPausedOperationStatus } from '../../git/models/pausedOperationStatus';
import { statusStringsByType } from '../../git/models/pausedOperationStatus';
import { getReferenceLabel } from '../../git/models/reference.utils';
import type { GitStatus } from '../../git/models/status';
import { pausedOperationStatusStringsByType } from '../../git/utils/pausedOperationStatus.utils';
import { pluralize } from '../../system/string';
import { executeCoreCommand } from '../../system/vscode/command';
import type { ViewsWithCommits } from '../viewBase';
Expand Down Expand Up @@ -110,7 +110,7 @@ export class PausedOperationStatusNode extends ViewNode<'paused-operation-status
const hasConflicts = this.status?.hasConflicts === true;

if (this.pausedOpStatus.type !== 'rebase') {
const strings = statusStringsByType[this.pausedOpStatus.type];
const strings = pausedOperationStatusStringsByType[this.pausedOpStatus.type];
return `${hasConflicts ? strings.conflicts : strings.label} ${getReferenceLabel(
this.pausedOpStatus.incoming,
{
Expand All @@ -124,7 +124,7 @@ export class PausedOperationStatusNode extends ViewNode<'paused-operation-status
}

const started = this.pausedOpStatus.steps.total > 0;
const strings = statusStringsByType[this.pausedOpStatus.type];
const strings = pausedOperationStatusStringsByType[this.pausedOpStatus.type];
return `${hasConflicts ? strings.conflicts : started ? strings.label : strings.pending} ${getReferenceLabel(
this.pausedOpStatus.incoming,
{ expand: false, icon: false },
Expand All @@ -139,7 +139,7 @@ export class PausedOperationStatusNode extends ViewNode<'paused-operation-status

let tooltip;
if (this.pausedOpStatus.type !== 'rebase') {
const strings = statusStringsByType[this.pausedOpStatus.type];
const strings = pausedOperationStatusStringsByType[this.pausedOpStatus.type];
tooltip = `${strings.label} ${getReferenceLabel(this.pausedOpStatus.incoming, { label: false })} ${
strings.directionality
} ${getReferenceLabel(this.pausedOpStatus.current, { label: false })}${
Expand All @@ -149,7 +149,7 @@ export class PausedOperationStatusNode extends ViewNode<'paused-operation-status
}`;
} else {
const started = this.pausedOpStatus.steps.total > 0;
const strings = statusStringsByType[this.pausedOpStatus.type];
const strings = pausedOperationStatusStringsByType[this.pausedOpStatus.type];
tooltip = `${started ? strings.label : strings.pending} ${getReferenceLabel(this.pausedOpStatus.incoming, {
label: false,
})} ${strings.directionality} ${getReferenceLabel(this.pausedOpStatus.current ?? this.pausedOpStatus.onto, {
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/pullRequestNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { GitBranchReference } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { createRevisionRange } from '../../git/models/revision.utils';
import { getAheadBehindFilesQuery, getCommitsQuery } from '../../git/queryResults';
import { getIssueOrPullRequestMarkdownIcon, getIssueOrPullRequestThemeIcon } from '../../git/utils/icons';
import { getIssueOrPullRequestMarkdownIcon, getIssueOrPullRequestThemeIcon } from '../../git/utils/vscode/icons';
import { pluralize } from '../../system/string';
import type { ViewsWithCommits } from '../viewBase';
import { CacheableChildrenViewNode } from './abstract/cacheableChildrenViewNode';
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/repositoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getHighlanderProviders } from '../../git/models/remote';
import type { RepositoryChangeEvent, RepositoryFileSystemChangeEvent } from '../../git/models/repository';
import { Repository, RepositoryChange, RepositoryChangeComparisonMode } from '../../git/models/repository';
import type { GitStatus } from '../../git/models/status';
import { getRepositoryStatusIconPath } from '../../git/utils/icons';
import { getRepositoryStatusIconPath } from '../../git/utils/vscode/icons';
import type {
CloudWorkspace,
CloudWorkspaceRepositoryDescriptor,
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/worktreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getHighlanderProviderName } from '../../git/models/remote';
import { shortenRevision } from '../../git/models/revision.utils';
import type { GitStatus } from '../../git/models/status';
import type { GitWorktree } from '../../git/models/worktree';
import { getBranchIconPath } from '../../git/utils/icons';
import { getBranchIconPath } from '../../git/utils/vscode/icons';
import { gate } from '../../system/decorators/gate';
import { debug } from '../../system/decorators/log';
import { map } from '../../system/iterable';
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/worktreesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GlyphChars } from '../../constants';
import { PlusFeatures } from '../../features';
import type { GitUri } from '../../git/gitUri';
import type { Repository } from '../../git/models/repository';
import { sortWorktrees } from '../../git/utils/sorting';
import { sortWorktrees } from '../../git/utils/vscode/sorting';
import { filterMap } from '../../system/array';
import { debug } from '../../system/decorators/log';
import { map } from '../../system/iterable';
Expand Down
Loading

0 comments on commit 175807c

Please sign in to comment.