Browse Source

Extracts features into its own file

Avoids import issues
main
Eric Amodio 2 years ago
parent
commit
e4d8b7731c
12 changed files with 62 additions and 49 deletions
  1. +1
    -1
      src/commands/git/worktree.ts
  2. +3
    -2
      src/commands/quickCommand.steps.ts
  3. +1
    -2
      src/env/node/git/localGitProvider.ts
  4. +14
    -0
      src/features.ts
  5. +8
    -16
      src/git/gitProvider.ts
  6. +1
    -6
      src/git/gitProviderService.ts
  7. +14
    -14
      src/git/models/repository.ts
  8. +8
    -4
      src/premium/github/githubGitProvider.ts
  9. +1
    -1
      src/views/nodes/repositoryNode.ts
  10. +1
    -1
      src/views/nodes/worktreesNode.ts
  11. +1
    -1
      src/views/worktreesView.ts
  12. +9
    -1
      src/webviews/apps/tsconfig.json

+ 1
- 1
src/commands/git/worktree.ts View File

@ -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';

+ 3
- 2
src/commands/quickCommand.steps.ts View File

@ -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,

+ 1
- 2
src/env/node/git/localGitProvider.ts View File

@ -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,

+ 14
- 0
src/features.ts View File

@ -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',
}

+ 8
- 16
src/git/gitProvider.ts View File

@ -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',

+ 1
- 6
src/git/gitProviderService.ts View File

@ -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;

+ 14
- 14
src/git/models/repository.ts View File

@ -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;

+ 8
- 4
src/premium/github/githubGitProvider.ts View File

@ -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<Features, boolean>();
async supports(_feature: Features): Promise<boolean> {
async supports(feature: Features): Promise<boolean> {
// 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<RepositoryVisibility> {

+ 1
- 1
src/views/nodes/repositoryNode.ts View File

@ -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,

+ 1
- 1
src/views/nodes/worktreesNode.ts View File

@ -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';

+ 1
- 1
src/views/worktreesView.ts View File

@ -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';

+ 9
- 1
src/webviews/apps/tsconfig.json View File

@ -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"]
}

Loading…
Cancel
Save