Skip to content

Commit c39ec45

Browse files
committed
Refactors shared location storage
- Uses XDG env vars on all OSs - Avoids singleton & adds to container - Avoids empty implementations for web - Renames files and methods for better clarity - Removes dependency on xdg-basedir package Adds new Lazy<T> type & lazy method Adds new UnifiedDisposable & UnifiedAsyncDisposable
1 parent 0f4c914 commit c39ec45

23 files changed

+541
-525
lines changed

ThirdPartyNotices.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ This project incorporates components from the projects listed below.
3333
28. signal-utils version 0.21.1 (https://github.com/proposal-signals/signal-utils)
3434
29. slug version 10.0.0 (https://github.com/Trott/slug)
3535
30. sortablejs version 1.15.0 (https://github.com/SortableJS/Sortable)
36-
31. xdg-basedir version 5.1.0 (https://github.com/sindresorhus/xdg-basedir)
3736

3837
%% @gk-nzaytsev/fast-string-truncated-width NOTICES AND INFORMATION BEGIN HERE
3938
=========================================
@@ -2245,19 +2244,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22452244
SOFTWARE.
22462245

22472246
=========================================
2248-
END OF sortablejs NOTICES AND INFORMATION
2249-
2250-
%% xdg-basedir NOTICES AND INFORMATION BEGIN HERE
2251-
=========================================
2252-
MIT License
2253-
2254-
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
2255-
2256-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2257-
2258-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2259-
2260-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2261-
2262-
=========================================
2263-
END OF xdg-basedir NOTICES AND INFORMATION
2247+
END OF sortablejs NOTICES AND INFORMATION

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20147,8 +20147,7 @@
2014720147
"react-dom": "16.8.4",
2014820148
"signal-utils": "0.21.1",
2014920149
"slug": "10.0.0",
20150-
"sortablejs": "1.15.0",
20151-
"xdg-basedir": "5.1.0"
20150+
"sortablejs": "1.15.0"
2015220151
},
2015320152
"devDependencies": {
2015420153
"@eamodio/eslint-lite-webpack-plugin": "0.2.0",

pnpm-lock.yaml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/container.ts

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type { ConfigurationChangeEvent, Disposable, Event, ExtensionContext } from 'vscode';
22
import { EventEmitter, ExtensionMode, Uri } from 'vscode';
3-
import { getSupportedGitProviders, getSupportedRepositoryPathMappingProvider } from '@env/providers';
3+
import {
4+
getSharedGKStorageLocationProvider,
5+
getSupportedGitProviders,
6+
getSupportedRepositoryLocationProvider,
7+
getSupportedWorkspacesStorageProvider,
8+
} from '@env/providers';
49
import type { AIProviderService } from './ai/aiProviderService';
510
import { FileAnnotationController } from './annotations/fileAnnotationController';
611
import { LineAnnotationController } from './annotations/lineAnnotationController';
@@ -18,7 +23,7 @@ import { GlCommand } from './constants.commands';
1823
import { EventBus } from './eventBus';
1924
import { GitFileSystemProvider } from './git/fsProvider';
2025
import { GitProviderService } from './git/gitProviderService';
21-
import type { RepositoryPathMappingProvider } from './git/pathMapping/repositoryPathMappingProvider';
26+
import type { RepositoryLocationProvider } from './git/location/repositorylocationProvider';
2227
import { LineHoverController } from './hovers/lineHoverController';
2328
import { DraftService } from './plus/drafts/draftsService';
2429
import { AccountAuthenticationProvider } from './plus/gk/authenticationProvider';
@@ -35,6 +40,8 @@ import { EnrichmentService } from './plus/launchpad/enrichmentService';
3540
import { LaunchpadIndicator } from './plus/launchpad/launchpadIndicator';
3641
import { LaunchpadProvider } from './plus/launchpad/launchpadProvider';
3742
import { RepositoryIdentityService } from './plus/repos/repositoryIdentityService';
43+
import type { SharedGkStorageLocationProvider } from './plus/repos/sharedGkStorageLocationProvider';
44+
import { WorkspacesApi } from './plus/workspaces/workspacesApi';
3845
import { scheduleAddMissingCurrentWorkspaceRepos, WorkspacesService } from './plus/workspaces/workspacesService';
3946
import { StatusBarController } from './statusbar/statusBarController';
4047
import { executeCommand } from './system/-webview/command';
@@ -404,14 +411,6 @@ export class Container {
404411
return this._drafts;
405412
}
406413

407-
private _repositoryIdentity: RepositoryIdentityService | undefined;
408-
get repositoryIdentity(): RepositoryIdentityService {
409-
if (this._repositoryIdentity == null) {
410-
this._disposables.push((this._repositoryIdentity = new RepositoryIdentityService(this, this._connection)));
411-
}
412-
return this._repositoryIdentity;
413-
}
414-
415414
private readonly _codeLensController: GitCodeLensController;
416415
get codeLens(): GitCodeLensController {
417416
return this._codeLensController;
@@ -587,12 +586,33 @@ export class Container {
587586
return this._rebaseEditor;
588587
}
589588

590-
private _repositoryPathMapping: RepositoryPathMappingProvider | undefined;
591-
get repositoryPathMapping(): RepositoryPathMappingProvider {
592-
if (this._repositoryPathMapping == null) {
593-
this._disposables.push((this._repositoryPathMapping = getSupportedRepositoryPathMappingProvider(this)));
589+
private _repositoryIdentity: RepositoryIdentityService | undefined;
590+
get repositoryIdentity(): RepositoryIdentityService {
591+
if (this._repositoryIdentity == null) {
592+
this._disposables.push(
593+
(this._repositoryIdentity = new RepositoryIdentityService(this, this.repositoryLocator)),
594+
);
595+
}
596+
return this._repositoryIdentity;
597+
}
598+
599+
private _repositoryLocator: RepositoryLocationProvider | null | undefined;
600+
get repositoryLocator(): RepositoryLocationProvider | undefined {
601+
if (this._repositoryLocator === undefined) {
602+
this._repositoryLocator = getSupportedRepositoryLocationProvider(this, this.sharedGkStorage!) ?? null;
603+
if (this._repositoryLocator != null) {
604+
this._disposables.push(this._repositoryLocator);
605+
}
606+
}
607+
return this._repositoryLocator ?? undefined;
608+
}
609+
610+
private _sharedGkStorage: SharedGkStorageLocationProvider | null | undefined;
611+
private get sharedGkStorage(): SharedGkStorageLocationProvider | undefined {
612+
if (this._sharedGkStorage === undefined) {
613+
this._sharedGkStorage = getSharedGKStorageLocationProvider(this) ?? null;
594614
}
595-
return this._repositoryPathMapping;
615+
return this._sharedGkStorage ?? undefined;
596616
}
597617

598618
private readonly _statusBarController: StatusBarController;
@@ -648,7 +668,14 @@ export class Container {
648668
private _workspaces: WorkspacesService | undefined;
649669
get workspaces(): WorkspacesService {
650670
if (this._workspaces == null) {
651-
this._disposables.push((this._workspaces = new WorkspacesService(this, this._connection)));
671+
this._disposables.push(
672+
(this._workspaces = new WorkspacesService(
673+
this,
674+
new WorkspacesApi(this, this._connection),
675+
getSupportedWorkspacesStorageProvider(this, this.sharedGkStorage!),
676+
this.repositoryLocator,
677+
)),
678+
);
652679
}
653680
return this._workspaces;
654681
}

src/env/browser/pathMapping/repositoryWebPathMappingProvider.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/env/browser/pathMapping/workspacesWebPathMappingProvider.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/env/browser/providers.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import type { GitCommandOptions } from '../../git/commandOptions';
33
// Force import of GitHub since dynamic imports are not supported in the WebWorker ExtensionHost
44
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
55
import { GitProvider } from '../../git/gitProvider';
6+
import type { RepositoryLocationProvider } from '../../git/location/repositorylocationProvider';
67
import { GitHubGitProvider } from '../../plus/integrations/providers/github/githubGitProvider';
7-
import { RepositoryWebPathMappingProvider } from './pathMapping/repositoryWebPathMappingProvider';
8-
import { WorkspacesWebPathMappingProvider } from './pathMapping/workspacesWebPathMappingProvider';
8+
import type { SharedGkStorageLocationProvider } from '../../plus/repos/sharedGkStorageLocationProvider';
9+
import type { GkWorkspacesSharedStorageProvider } from '../../plus/workspaces/workspacesSharedStorageProvider';
910

1011
export function git(_options: GitCommandOptions, ..._args: any[]): Promise<string | Buffer> {
1112
return Promise.resolve('');
@@ -25,10 +26,20 @@ export function getSupportedGitProviders(container: Container): Promise<GitProvi
2526
return Promise.resolve([new GitHubGitProvider(container)]);
2627
}
2728

28-
export function getSupportedRepositoryPathMappingProvider(container: Container) {
29-
return new RepositoryWebPathMappingProvider(container);
29+
export function getSharedGKStorageLocationProvider(_container: Container): SharedGkStorageLocationProvider | undefined {
30+
return undefined;
3031
}
3132

32-
export function getSupportedWorkspacesPathMappingProvider() {
33-
return new WorkspacesWebPathMappingProvider();
33+
export function getSupportedRepositoryLocationProvider(
34+
_container: Container,
35+
_sharedStorage: SharedGkStorageLocationProvider | undefined,
36+
): RepositoryLocationProvider | undefined {
37+
return undefined;
38+
}
39+
40+
export function getSupportedWorkspacesStorageProvider(
41+
_container: Container,
42+
_sharedStorage: SharedGkStorageLocationProvider | undefined,
43+
): GkWorkspacesSharedStorageProvider | undefined {
44+
return undefined;
3445
}

0 commit comments

Comments
 (0)