|
@ -25,7 +25,7 @@ import { |
|
|
OpenVirtualRepositoryError, |
|
|
OpenVirtualRepositoryError, |
|
|
OpenVirtualRepositoryErrorReason, |
|
|
OpenVirtualRepositoryErrorReason, |
|
|
} from '../../errors'; |
|
|
} from '../../errors'; |
|
|
import { Features, PlusFeatures } from '../../features'; |
|
|
|
|
|
|
|
|
import { Features } from '../../features'; |
|
|
import { |
|
|
import { |
|
|
GitProvider, |
|
|
GitProvider, |
|
|
GitProviderId, |
|
|
GitProviderId, |
|
@ -38,7 +38,6 @@ import { |
|
|
RepositoryVisibility, |
|
|
RepositoryVisibility, |
|
|
ScmRepository, |
|
|
ScmRepository, |
|
|
} from '../../git/gitProvider'; |
|
|
} from '../../git/gitProvider'; |
|
|
import { GitProviderService } from '../../git/gitProviderService'; |
|
|
|
|
|
import { GitUri } from '../../git/gitUri'; |
|
|
import { GitUri } from '../../git/gitUri'; |
|
|
import { |
|
|
import { |
|
|
BranchSortOptions, |
|
|
BranchSortOptions, |
|
@ -82,12 +81,10 @@ import { RemoteProviderFactory, RemoteProviders } from '../../git/remotes/factor |
|
|
import { RemoteProvider, RichRemoteProvider } from '../../git/remotes/provider'; |
|
|
import { RemoteProvider, RichRemoteProvider } from '../../git/remotes/provider'; |
|
|
import { SearchPattern } from '../../git/search'; |
|
|
import { SearchPattern } from '../../git/search'; |
|
|
import { LogCorrelationContext, Logger } from '../../logger'; |
|
|
import { LogCorrelationContext, Logger } from '../../logger'; |
|
|
import { SubscriptionPlanId } from '../../subscription'; |
|
|
|
|
|
import { gate } from '../../system/decorators/gate'; |
|
|
import { gate } from '../../system/decorators/gate'; |
|
|
import { debug, log } from '../../system/decorators/log'; |
|
|
import { debug, log } from '../../system/decorators/log'; |
|
|
import { filterMap, some } from '../../system/iterable'; |
|
|
import { filterMap, some } from '../../system/iterable'; |
|
|
import { isAbsolute, isFolderGlob, maybeUri, normalizePath, relative } from '../../system/path'; |
|
|
import { isAbsolute, isFolderGlob, maybeUri, normalizePath, relative } from '../../system/path'; |
|
|
import { fastestSettled } from '../../system/promise'; |
|
|
|
|
|
import { CachedBlame, CachedLog, GitDocumentState } from '../../trackers/gitDocumentTracker'; |
|
|
import { CachedBlame, CachedLog, GitDocumentState } from '../../trackers/gitDocumentTracker'; |
|
|
import { TrackedDocument } from '../../trackers/trackedDocument'; |
|
|
import { TrackedDocument } from '../../trackers/trackedDocument'; |
|
|
import { getRemoteHubApi, GitHubAuthorityMetadata, Metadata, RemoteHubApi } from '../remotehub'; |
|
|
import { getRemoteHubApi, GitHubAuthorityMetadata, Metadata, RemoteHubApi } from '../remotehub'; |
|
@ -189,36 +186,6 @@ export class GitHubGitProvider implements GitProvider, Disposable { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private _allowedFeatures = new Map<string, Map<PlusFeatures, boolean>>(); |
|
|
|
|
|
async allows(feature: PlusFeatures, plan: SubscriptionPlanId, repoPath?: string): Promise<boolean> { |
|
|
|
|
|
if (plan === SubscriptionPlanId.Free) return false; |
|
|
|
|
|
if (plan === SubscriptionPlanId.Pro) return true; |
|
|
|
|
|
|
|
|
|
|
|
if (repoPath == null) { |
|
|
|
|
|
const repositories = [...this.container.git.getOpenRepositories(this.descriptor.id)]; |
|
|
|
|
|
|
|
|
|
|
|
for await (const result of fastestSettled(repositories.map(r => this.allows(feature, plan, r.path)))) { |
|
|
|
|
|
if (result.status !== 'fulfilled' || !result.value) return false; |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let allowedByRepo = this._allowedFeatures.get(repoPath); |
|
|
|
|
|
let allowed = allowedByRepo?.get(feature); |
|
|
|
|
|
if (allowed != null) return allowed; |
|
|
|
|
|
|
|
|
|
|
|
allowed = GitProviderService.previewFeatures?.get(feature) |
|
|
|
|
|
? true |
|
|
|
|
|
: (await this.visibility(repoPath)) === RepositoryVisibility.Public; |
|
|
|
|
|
if (allowedByRepo == null) { |
|
|
|
|
|
allowedByRepo = new Map<PlusFeatures, boolean>(); |
|
|
|
|
|
this._allowedFeatures.set(repoPath, allowedByRepo); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
allowedByRepo.set(feature, allowed); |
|
|
|
|
|
return allowed; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// private _supportedFeatures = new Map<Features, boolean>();
|
|
|
// private _supportedFeatures = new Map<Features, boolean>();
|
|
|
async supports(feature: Features): Promise<boolean> { |
|
|
async supports(feature: Features): Promise<boolean> { |
|
|
// const supported = this._supportedFeatures.get(feature);
|
|
|
// const supported = this._supportedFeatures.get(feature);
|
|
|