diff --git a/src/commands/git/worktree.ts b/src/commands/git/worktree.ts index 8e8f19b..c5c3459 100644 --- a/src/commands/git/worktree.ts +++ b/src/commands/git/worktree.ts @@ -1,13 +1,13 @@ import { MessageItem, QuickInputButtons, Uri, window } from 'vscode'; import { configuration } from '../../configuration'; import { Container } from '../../container'; +import { PremiumFeatures } from '../../features'; import { WorktreeCreateError, WorktreeCreateErrorReason, WorktreeDeleteError, WorktreeDeleteErrorReason, } from '../../git/errors'; -import { PremiumFeatures } from '../../git/gitProvider'; import { GitReference, GitWorktree, Repository } from '../../git/models'; import { Messages } from '../../messages'; import { QuickPickItemOfT, QuickPickSeparator } from '../../quickpicks/items/common'; diff --git a/src/commands/quickCommand.steps.ts b/src/commands/quickCommand.steps.ts index 59db43d..6b749bb 100644 --- a/src/commands/quickCommand.steps.ts +++ b/src/commands/quickCommand.steps.ts @@ -2,7 +2,8 @@ import { QuickInputButton, QuickPick } from 'vscode'; import { BranchSorting, configuration, TagSorting } from '../configuration'; import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants'; import { Container } from '../container'; -import { PagedResult, PremiumFeatures } from '../git/gitProvider'; +import type { PremiumFeatures } from '../features'; +import type { PagedResult } from '../git/gitProvider'; import { BranchSortOptions, GitBranch, @@ -72,7 +73,7 @@ import { formatPath } from '../system/formatPath'; import { map } from '../system/iterable'; import { pad, pluralize, truncate } from '../system/string'; import { OpenWorkspaceLocation } from '../system/utils'; -import { ViewsWithRepositoryFolders } from '../views/viewBase'; +import type { ViewsWithRepositoryFolders } from '../views/viewBase'; import { GitActions } from './gitCommands.actions'; import { AsyncStepResultGenerator, diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index 2b9239a..75ae508 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -26,6 +26,7 @@ import type { import { configuration } from '../../../configuration'; import { CoreGitConfiguration, GlyphChars, Schemes } from '../../../constants'; import type { Container } from '../../../container'; +import { Features, PremiumFeatures } from '../../../features'; import { StashApplyError, StashApplyErrorReason, @@ -35,13 +36,11 @@ import { WorktreeDeleteErrorReason, } from '../../../git/errors'; import { - Features, GitProvider, GitProviderDescriptor, GitProviderId, NextComparisionUrisResult, PagedResult, - PremiumFeatures, PreviousComparisionUrisResult, PreviousLineComparisionUrisResult, RepositoryCloseEvent, diff --git a/src/features.ts b/src/features.ts new file mode 100644 index 0000000..e484f40 --- /dev/null +++ b/src/features.ts @@ -0,0 +1,14 @@ +import type { RequiredSubscriptionPlans, Subscription } from './subscription'; + +export const enum Features { + Stashes = 'stashes', + Worktrees = 'worktrees', +} + +export type FeatureAccess = + | { allowed: true; subscription: { current: Subscription; required?: undefined } } + | { allowed: false; subscription: { current: Subscription; required?: RequiredSubscriptionPlans } }; + +export const enum PremiumFeatures { + Worktrees = 'worktrees', +} diff --git a/src/git/gitProvider.ts b/src/git/gitProvider.ts index 0aa859b..d2d1ace 100644 --- a/src/git/gitProvider.ts +++ b/src/git/gitProvider.ts @@ -1,8 +1,9 @@ import { Disposable, Event, Range, TextDocument, Uri, WorkspaceFolder } from 'vscode'; -import { Commit, InputBox } from '../@types/vscode.git'; -import { SubscriptionPlanId } from '../subscription'; -import { GitUri } from './gitUri'; -import { +import type { Commit, InputBox } from '../@types/vscode.git'; +import { Features, PremiumFeatures } from '../features'; +import type { SubscriptionPlanId } from '../subscription'; +import type { GitUri } from './gitUri'; +import type { BranchSortOptions, GitBlame, GitBlameLine, @@ -32,9 +33,9 @@ import { RepositoryChangeEvent, TagSortOptions, } from './models'; -import { RemoteProviders } from './remotes/factory'; -import { RemoteProvider, RichRemoteProvider } from './remotes/provider'; -import { SearchPattern } from './search'; +import type { RemoteProviders } from './remotes/factory'; +import type { RemoteProvider, RichRemoteProvider } from './remotes/provider'; +import type { SearchPattern } from './search'; export const enum GitProviderId { Git = 'git', @@ -90,15 +91,6 @@ export interface RepositoryOpenEvent { readonly uri: Uri; } -export const enum Features { - Stashes = 'stashes', - Worktrees = 'worktrees', -} - -export const enum PremiumFeatures { - Worktrees = 'worktrees', -} - export const enum RepositoryVisibility { Private = 'private', Public = 'public', diff --git a/src/git/gitProviderService.ts b/src/git/gitProviderService.ts index c1bf2bb..3c4ea19 100644 --- a/src/git/gitProviderService.ts +++ b/src/git/gitProviderService.ts @@ -21,6 +21,7 @@ import { ContextKeys, CoreGitConfiguration, GlyphChars, Schemes } from '../const import type { Container } from '../container'; import { setContext } from '../context'; import { AccessDeniedError, ProviderNotFoundError } from '../errors'; +import type { FeatureAccess, Features, PremiumFeatures } from '../features'; import { Logger } from '../logger'; import type { SubscriptionChangeEvent } from '../premium/subscription/subscriptionService'; import { asRepoComparisonKey, RepoComparisionKey, Repositories } from '../repositories'; @@ -41,13 +42,11 @@ import { dirname, getBestPath, getScheme, isAbsolute, maybeUri, normalizePath } import { cancellable, isPromise, PromiseCancelledError } from '../system/promise'; import { VisitedPathsTrie } from '../system/trie'; import { - Features, GitProvider, GitProviderDescriptor, GitProviderId, NextComparisionUrisResult, PagedResult, - PremiumFeatures, PreviousComparisionUrisResult, PreviousLineComparisionUrisResult, RepositoryVisibility, @@ -113,10 +112,6 @@ export type RepositoriesChangeEvent = { readonly removed: readonly Repository[]; }; -export type FeatureAccess = - | { allowed: true; subscription: { current: Subscription; required?: undefined } } - | { allowed: false; subscription: { current: Subscription; required?: RequiredSubscriptionPlans } }; - export interface GitProviderResult { provider: GitProvider; path: string; diff --git a/src/git/models/repository.ts b/src/git/models/repository.ts index 0f8226a..4f512de 100644 --- a/src/git/models/repository.ts +++ b/src/git/models/repository.ts @@ -14,6 +14,7 @@ import type { CreatePullRequestActionContext } from '../../api/gitlens'; import { configuration } from '../../configuration'; import { CoreGitCommands, CoreGitConfiguration, Schemes } from '../../constants'; import { Container } from '../../container'; +import type { FeatureAccess, Features, PremiumFeatures } from '../../features'; import { Logger } from '../../logger'; import { Messages } from '../../messages'; import { asRepoComparisonKey } from '../../repositories'; @@ -27,24 +28,23 @@ import { debounce } from '../../system/function'; import { filter, join, some } from '../../system/iterable'; import { basename, normalizePath } from '../../system/path'; import { runGitCommandInTerminal } from '../../terminal'; -import { Features, GitProviderDescriptor, PremiumFeatures } from '../gitProvider'; -import { FeatureAccess } from '../gitProviderService'; +import type { GitProviderDescriptor } from '../gitProvider'; import { RemoteProviderFactory, RemoteProviders } from '../remotes/factory'; import { RichRemoteProvider } from '../remotes/provider'; -import { SearchPattern } from '../search'; +import type { SearchPattern } from '../search'; import { BranchSortOptions, GitBranch } from './branch'; -import { GitCommit } from './commit'; -import { GitContributor } from './contributor'; -import { GitDiffShortStat } from './diff'; -import { GitLog } from './log'; -import { GitMergeStatus } from './merge'; -import { GitRebaseStatus } from './rebase'; +import type { GitCommit } from './commit'; +import type { GitContributor } from './contributor'; +import type { GitDiffShortStat } from './diff'; +import type { GitLog } from './log'; +import type { GitMergeStatus } from './merge'; +import type { GitRebaseStatus } from './rebase'; import { GitBranchReference, GitReference, GitTagReference } from './reference'; -import { GitRemote } from './remote'; -import { GitStash } from './stash'; -import { GitStatus } from './status'; -import { GitTag, TagSortOptions } from './tag'; -import { GitWorktree } from './worktree'; +import type { GitRemote } from './remote'; +import type { GitStash } from './stash'; +import type { GitStatus } from './status'; +import type { GitTag, TagSortOptions } from './tag'; +import type { GitWorktree } from './worktree'; const millisecondsPerMinute = 60 * 1000; const millisecondsPerHour = 60 * 60 * 1000; diff --git a/src/premium/github/githubGitProvider.ts b/src/premium/github/githubGitProvider.ts index e8ec592..146e271 100644 --- a/src/premium/github/githubGitProvider.ts +++ b/src/premium/github/githubGitProvider.ts @@ -25,13 +25,12 @@ import { OpenVirtualRepositoryError, OpenVirtualRepositoryErrorReason, } from '../../errors'; +import { Features, PremiumFeatures } from '../../features'; import { - Features, GitProvider, GitProviderId, NextComparisionUrisResult, PagedResult, - PremiumFeatures, PreviousComparisionUrisResult, PreviousLineComparisionUrisResult, RepositoryCloseEvent, @@ -217,11 +216,16 @@ export class GitHubGitProvider implements GitProvider, Disposable { } // private _supportedFeatures = new Map(); - async supports(_feature: Features): Promise { + async supports(feature: Features): Promise { // const supported = this._supportedFeatures.get(feature); // if (supported != null) return supported; - return false; + switch (feature) { + case Features.Worktrees: + return false; + default: + return true; + } } async visibility(repoPath: string): Promise { diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts index c6aeda6..9796d2b 100644 --- a/src/views/nodes/repositoryNode.ts +++ b/src/views/nodes/repositoryNode.ts @@ -1,6 +1,6 @@ import { Disposable, MarkdownString, TreeItem, TreeItemCollapsibleState } from 'vscode'; import { GlyphChars } from '../../constants'; -import { Features } from '../../git/gitProvider'; +import { Features } from '../../features'; import { GitUri } from '../../git/gitUri'; import { GitBranch, diff --git a/src/views/nodes/worktreesNode.ts b/src/views/nodes/worktreesNode.ts index 93a4864..a6a2cef 100644 --- a/src/views/nodes/worktreesNode.ts +++ b/src/views/nodes/worktreesNode.ts @@ -1,6 +1,6 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import { GlyphChars } from '../../constants'; -import { PremiumFeatures } from '../../git/gitProvider'; +import { PremiumFeatures } from '../../features'; import { GitUri } from '../../git/gitUri'; import { Repository } from '../../git/models'; import { gate } from '../../system/decorators/gate'; diff --git a/src/views/worktreesView.ts b/src/views/worktreesView.ts index 1c80101..1587fcd 100644 --- a/src/views/worktreesView.ts +++ b/src/views/worktreesView.ts @@ -11,7 +11,7 @@ import { } from 'vscode'; import { configuration, ViewFilesLayout, ViewShowBranchComparison, WorktreesViewConfig } from '../configuration'; import { Container } from '../container'; -import { PremiumFeatures } from '../git/gitProvider'; +import { PremiumFeatures } from '../features'; import { GitUri } from '../git/gitUri'; import { GitWorktree, RepositoryChange, RepositoryChangeComparisonMode, RepositoryChangeEvent } from '../git/models'; import { gate } from '../system/decorators/gate'; diff --git a/src/webviews/apps/tsconfig.json b/src/webviews/apps/tsconfig.json index 14fcd0b..b7eb412 100644 --- a/src/webviews/apps/tsconfig.json +++ b/src/webviews/apps/tsconfig.json @@ -4,6 +4,14 @@ "lib": ["dom", "dom.iterable", "es2020"], "outDir": "../../" }, - "include": ["**/*", "../../@types/**/*", "../../system/date.ts", "../../config.ts", "../protocol.ts"], + "include": [ + "**/*", + "../../@types/**/*", + "../protocol.ts", + "../../config.ts", + "../../features.ts", + "../../subscription.ts", + "../../system/date.ts" + ], "exclude": ["node_modules", "test"] }