Skip to content

Commit c33d4df

Browse files
committed
Removes more enums
1 parent 1f8ffaa commit c33d4df

File tree

24 files changed

+58
-91
lines changed

24 files changed

+58
-91
lines changed

docs/telemetry-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ or
20422042

20432043
```typescript
20442044
{
2045-
'context.key': 'gettingStarted' | 'visualizeCodeHistory' | 'prReviews' | 'streamlineCollaboration' | 'integrations'
2045+
'context.key': 'integrations' | 'gettingStarted' | 'visualizeCodeHistory' | 'prReviews' | 'streamlineCollaboration'
20462046
}
20472047
```
20482048

src/commands/git/push.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { GlyphChars } from '../../constants';
22
import type { Container } from '../../container';
3-
import { Features } from '../../features';
43
import type { GitBranchReference, GitReference } from '../../git/models/reference';
54
import type { Repository } from '../../git/models/repository';
65
import { getRemoteNameFromBranchName } from '../../git/utils/branch.utils';
@@ -158,7 +157,7 @@ export class PushGitCommand extends QuickCommand<State> {
158157
const useForceIfIncludes =
159158
useForceWithLease &&
160159
(configuration.getCore('git.useForcePushIfIncludes') ?? true) &&
161-
(await this.container.git.supports(state.repos[0].uri, Features.ForceIfIncludes));
160+
(await this.container.git.supports(state.repos[0].uri, 'forceIfIncludes'));
162161

163162
let step: QuickPickStep<FlagsQuickPickItem<Flags>>;
164163

src/commands/git/worktree.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { Config } from '../../config';
44
import { proBadge, proBadgeSuperscript } from '../../constants';
55
import type { Container } from '../../container';
66
import { CancellationError } from '../../errors';
7-
import { PlusFeatures } from '../../features';
87
import { executeGitCommand } from '../../git/actions';
98
import { convertLocationToOpenFlags, convertOpenFlagsToLocation, reveal } from '../../git/actions/worktree';
109
import {
@@ -309,7 +308,7 @@ export class WorktreeGitCommand extends QuickCommand<State> {
309308
}
310309
assertStateStepRepository(state);
311310

312-
const result = yield* ensureAccessStep(this.container, state, context, PlusFeatures.Worktrees);
311+
const result = yield* ensureAccessStep(this.container, state, context, 'worktrees');
313312
if (result === StepResultBreak) continue;
314313

315314
switch (state.subcommand) {

src/commands/quickCommand.steps.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import type { QuickInputButton, QuickPick, QuickPickItem } from 'vscode';
22
import { ThemeIcon } from 'vscode';
33
import { GlyphChars, quickPickTitleMaxChars } from '../constants';
44
import { Container } from '../container';
5-
import type { FeatureAccess, RepoFeatureAccess } from '../features';
6-
import { PlusFeatures } from '../features';
5+
import type { FeatureAccess, PlusFeatures, RepoFeatureAccess } from '../features';
76
import * as BranchActions from '../git/actions/branch';
87
import * as CommitActions from '../git/actions/commit';
98
import * as ContributorActions from '../git/actions/contributor';
@@ -2688,7 +2687,7 @@ export async function* ensureAccessStep<
26882687
}
26892688

26902689
switch (feature) {
2691-
case PlusFeatures.Launchpad:
2690+
case 'launchpad' satisfies PlusFeatures:
26922691
directives.splice(
26932692
0,
26942693
0,
@@ -2705,7 +2704,7 @@ export async function* ensureAccessStep<
27052704
createQuickPickSeparator(),
27062705
);
27072706
break;
2708-
case PlusFeatures.StartWork:
2707+
case 'startWork' satisfies PlusFeatures:
27092708
directives.splice(
27102709
0,
27112710
0,
@@ -2716,7 +2715,7 @@ export async function* ensureAccessStep<
27162715
createQuickPickSeparator(),
27172716
);
27182717
break;
2719-
case PlusFeatures.AssociateIssueWithBranch:
2718+
case 'associateIssueWithBranch' satisfies PlusFeatures:
27202719
directives.splice(
27212720
0,
27222721
0,
@@ -2727,7 +2726,7 @@ export async function* ensureAccessStep<
27272726
createQuickPickSeparator(),
27282727
);
27292728
break;
2730-
case PlusFeatures.Worktrees:
2729+
case 'worktrees' satisfies PlusFeatures:
27312730
directives.splice(
27322731
0,
27332732
0,

src/commands/stashSave.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { Uri } from 'vscode';
22
import type { ScmResource } from '../@types/vscode.git.resources';
33
import { ScmResourceGroupType, ScmStatus } from '../@types/vscode.git.resources.enums';
44
import type { Container } from '../container';
5-
import { Features } from '../features';
65
import { push } from '../git/actions/stash';
76
import { GitUri } from '../git/gitUri';
87
import { command } from '../system/-webview/command';
@@ -77,7 +76,7 @@ export class StashSaveCommand extends GlCommandBase {
7776
const repo = await this.container.git.getOrOpenRepository(uris[0]);
7877

7978
args.repoPath = repo?.path;
80-
args.onlyStaged = repo != null && hasOnlyStaged ? await repo.git.supports(Features.StashOnlyStaged) : false;
79+
args.onlyStaged = repo != null && hasOnlyStaged ? await repo.git.supports('stashOnlyStaged') : false;
8180
if (args.keepStaged == null && !hasStaged) {
8281
args.keepStaged = true;
8382
}
@@ -116,7 +115,7 @@ export class StashSaveCommand extends GlCommandBase {
116115
const repo = await this.container.git.getOrOpenRepository(uris[0]);
117116

118117
args.repoPath = repo?.path;
119-
args.onlyStaged = repo != null && hasOnlyStaged ? await repo.git.supports(Features.StashOnlyStaged) : false;
118+
args.onlyStaged = repo != null && hasOnlyStaged ? await repo.git.supports('stashOnlyStaged') : false;
120119
if (args.keepStaged == null && !hasStaged) {
121120
args.keepStaged = true;
122121
}

src/env/node/git/localGitProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { isLinux, isWindows } from '@env/platform';
99
import type { GitExtension, API as ScmGitApi } from '../../../@types/vscode.git';
1010
import { GlyphChars, Schemes } from '../../../constants';
1111
import type { Container } from '../../../container';
12-
import { Features } from '../../../features';
12+
import type { Features } from '../../../features';
1313
import { GitCache } from '../../../git/cache';
1414
import { GitErrorHandling } from '../../../git/commandOptions';
1515
import {
@@ -463,15 +463,15 @@ export class LocalGitProvider implements GitProvider, Disposable {
463463
if (supported != null) return supported;
464464

465465
switch (feature) {
466-
case Features.Worktrees:
466+
case 'worktrees' satisfies Features:
467467
supported = await this.git.isAtLeastVersion('2.17.0');
468468
this._supportedFeatures.set(feature, supported);
469469
return supported;
470-
case Features.StashOnlyStaged:
470+
case 'stashOnlyStaged' satisfies Features:
471471
supported = await this.git.isAtLeastVersion('2.35.0');
472472
this._supportedFeatures.set(feature, supported);
473473
return supported;
474-
case Features.ForceIfIncludes:
474+
case 'forceIfIncludes' satisfies Features:
475475
supported = await this.git.isAtLeastVersion('2.30.0');
476476
this._supportedFeatures.set(feature, supported);
477477
return supported;

src/features.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ import type { RepositoryVisibility } from './git/gitProvider';
44
import type { RequiredSubscriptionPlans, Subscription } from './plus/gk/models/subscription';
55
import { capitalize } from './system/string';
66

7-
export const enum Features {
8-
Stashes = 'stashes',
9-
Timeline = 'timeline',
10-
Worktrees = 'worktrees',
11-
StashOnlyStaged = 'stashOnlyStaged',
12-
ForceIfIncludes = 'forceIfIncludes',
13-
}
7+
export type Features = 'stashes' | 'timeline' | 'worktrees' | 'stashOnlyStaged' | 'forceIfIncludes';
148

159
export type FeatureAccess =
1610
| {
@@ -36,14 +30,7 @@ export type RepoFeatureAccess =
3630
visibility?: RepositoryVisibility;
3731
};
3832

39-
export const enum PlusFeatures {
40-
Timeline = 'timeline',
41-
Worktrees = 'worktrees',
42-
Graph = 'graph',
43-
Launchpad = 'launchpad',
44-
StartWork = 'startWork',
45-
AssociateIssueWithBranch = 'associateIssueWithBranch',
46-
}
33+
export type PlusFeatures = 'timeline' | 'worktrees' | 'graph' | 'launchpad' | 'startWork' | 'associateIssueWithBranch';
4734

4835
export type FeaturePreviews = 'graph';
4936
export const featurePreviews: FeaturePreviews[] = ['graph'];

src/git/models/issue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Issue implements IssueShape {
4040
) {}
4141
}
4242

43-
export enum RepositoryAccessLevel {
43+
export const enum RepositoryAccessLevel {
4444
Admin = 100,
4545
Maintain = 40,
4646
Write = 30,

src/plus/integrations/providers/github/githubGitProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
OpenVirtualRepositoryError,
2222
OpenVirtualRepositoryErrorReason,
2323
} from '../../../../errors';
24-
import { Features } from '../../../../features';
24+
import type { Features } from '../../../../features';
2525
import { GitCache } from '../../../../git/cache';
2626
import type {
2727
GitProvider,
@@ -248,9 +248,9 @@ export class GitHubGitProvider implements GitProvider, Disposable {
248248
// if (supported != null) return supported;
249249

250250
switch (feature) {
251-
case Features.Stashes:
252-
case Features.Worktrees:
253-
case Features.StashOnlyStaged:
251+
case 'stashes' satisfies Features:
252+
case 'worktrees' satisfies Features:
253+
case 'stashOnlyStaged' satisfies Features:
254254
return false;
255255
default:
256256
return true;

src/plus/integrations/providers/models.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,20 @@ export function isCloudSelfHostedIntegrationId(id: IntegrationId): id is CloudSe
112112
return id === SelfHostedIntegrationId.CloudGitHubEnterprise || id === SelfHostedIntegrationId.CloudGitLabSelfHosted;
113113
}
114114

115-
export enum PullRequestFilter {
115+
export const enum PullRequestFilter {
116116
Author = 'author',
117117
Assignee = 'assignee',
118118
ReviewRequested = 'review-requested',
119119
Mention = 'mention',
120120
}
121121

122-
export enum IssueFilter {
122+
export const enum IssueFilter {
123123
Author = 'author',
124124
Assignee = 'assignee',
125125
Mention = 'mention',
126126
}
127127

128-
export enum PagingMode {
128+
export const enum PagingMode {
129129
Project = 'project',
130130
Repo = 'repo',
131131
Repos = 'repos',

0 commit comments

Comments
 (0)