Skip to content

Commit b0b014c

Browse files
committed
Adds type safety to date ordering
1 parent d284973 commit b0b014c

File tree

5 files changed

+50
-32
lines changed

5 files changed

+50
-32
lines changed

src/env/node/git/git.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ export class Git {
705705
authors?: GitUser[];
706706
limit?: number;
707707
merges?: boolean;
708-
ordering?: string | null;
708+
ordering?: 'date' | 'author-date' | 'topo' | null;
709709
similarityThreshold?: number | null;
710710
since?: number | string;
711711
until?: number | string;
@@ -796,7 +796,7 @@ export class Git {
796796
filters?: GitDiffFilter[];
797797
firstParent?: boolean;
798798
limit?: number;
799-
ordering?: string | null;
799+
ordering?: 'date' | 'author-date' | 'topo' | null;
800800
renames?: boolean;
801801
reverse?: boolean;
802802
since?: string;
@@ -890,7 +890,7 @@ export class Git {
890890
repoPath: string,
891891
fileName: string,
892892
options?: {
893-
ordering?: string | null;
893+
ordering?: 'date' | 'author-date' | 'topo' | null;
894894
ref?: string;
895895
similarityThreshold?: number | null;
896896
cancellation?: CancellationToken;
@@ -929,7 +929,7 @@ export class Git {
929929
repoPath: string,
930930
objectId: string,
931931
ref: string,
932-
ordering: string | null,
932+
ordering: 'date' | 'author-date' | 'topo' | null,
933933
file?: string,
934934
cancellation?: CancellationToken,
935935
) {
@@ -955,7 +955,7 @@ export class Git {
955955
return data.length === 0 ? undefined : data.trim();
956956
}
957957

958-
async log__recent(repoPath: string, ordering?: string | null) {
958+
async log__recent(repoPath: string, ordering?: 'date' | 'author-date' | 'topo' | null) {
959959
const params = ['log', '-n1', '--format=%H'];
960960

961961
if (ordering) {
@@ -971,7 +971,7 @@ export class Git {
971971
return data.length === 0 ? undefined : data.trim();
972972
}
973973

974-
async log__recent_committerdate(repoPath: string, ordering?: string | null) {
974+
async log__recent_committerdate(repoPath: string, ordering?: 'date' | 'author-date' | 'topo' | null) {
975975
const params = ['log', '-n1', '--format=%ct'];
976976

977977
if (ordering) {
@@ -995,7 +995,7 @@ export class Git {
995995
ordering,
996996
skip,
997997
useShow,
998-
}: { limit?: number; ordering?: string | null; skip?: number; useShow?: boolean } = {},
998+
}: { limit?: number; ordering?: 'date' | 'author-date' | 'topo' | null; skip?: number; useShow?: boolean } = {},
999999
) {
10001000
const params = [
10011001
useShow ? 'show' : 'log',
@@ -1096,7 +1096,13 @@ export class Git {
10961096
limit,
10971097
ordering,
10981098
skip,
1099-
}: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number } = {},
1099+
}: {
1100+
all?: boolean;
1101+
branch?: string;
1102+
limit?: number;
1103+
ordering?: 'date' | 'author-date' | 'topo' | null;
1104+
skip?: number;
1105+
} = {},
11001106
): Promise<string> {
11011107
const params = ['log', '--walk-reflogs', `--format=${GitReflogParser.defaultFormat}`, '--date=iso8601'];
11021108

@@ -1188,7 +1194,7 @@ export class Git {
11881194

11891195
async rev_parse__currentBranch(
11901196
repoPath: string,
1191-
ordering: string | null,
1197+
ordering: 'date' | 'author-date' | 'topo' | null,
11921198
): Promise<[string, string | undefined] | undefined> {
11931199
try {
11941200
const data = await this.git<string>(

src/env/node/git/localGitProvider.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
20642064
cursor?: string;
20652065
limit?: number;
20662066
merges?: boolean;
2067-
ordering?: string | null;
2067+
ordering?: 'date' | 'author-date' | 'topo' | null;
20682068
ref?: string;
20692069
since?: number | string;
20702070
until?: number | string;
@@ -2148,7 +2148,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
21482148
cursor?: string;
21492149
limit?: number;
21502150
merges?: boolean;
2151-
ordering?: string | null;
2151+
ordering?: 'date' | 'author-date' | 'topo' | null;
21522152
ref?: string;
21532153
since?: string;
21542154
},
@@ -2186,7 +2186,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
21862186
authors?: GitUser[];
21872187
limit?: number;
21882188
merges?: boolean;
2189-
ordering?: string | null;
2189+
ordering?: 'date' | 'author-date' | 'topo' | null;
21902190
ref?: string;
21912191
},
21922192
): (limit: number | { until: string } | undefined) => Promise<GitLog> {
@@ -2423,7 +2423,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
24232423
cursor?: string;
24242424
force?: boolean | undefined;
24252425
limit?: number;
2426-
ordering?: string | null;
2426+
ordering?: 'date' | 'author-date' | 'topo' | null;
24272427
range?: Range;
24282428
ref?: string;
24292429
renames?: boolean;
@@ -2576,7 +2576,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
25762576
all?: boolean;
25772577
cursor?: string;
25782578
limit?: number;
2579-
ordering?: string | null;
2579+
ordering?: 'date' | 'author-date' | 'topo' | null;
25802580
range?: Range;
25812581
ref?: string;
25822582
renames?: boolean;
@@ -2657,7 +2657,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
26572657
options: {
26582658
all?: boolean;
26592659
limit?: number;
2660-
ordering?: string | null;
2660+
ordering?: 'date' | 'author-date' | 'topo' | null;
26612661
range?: Range;
26622662
ref?: string;
26632663
renames?: boolean;
@@ -3201,7 +3201,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
32013201
@log()
32023202
async getIncomingActivity(
32033203
repoPath: string,
3204-
options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
3204+
options?: { all?: boolean; branch?: string; limit?: number; ordering?: 'date' | 'author-date' | 'topo' | null; skip?: number },
32053205
): Promise<GitReflog | undefined> {
32063206
const scope = getLogScope();
32073207

@@ -3229,7 +3229,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
32293229

32303230
private getReflogMoreFn(
32313231
reflog: GitReflog,
3232-
options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
3232+
options?: { all?: boolean; branch?: string; limit?: number; ordering?: 'date' | 'author-date' | 'topo' | null; skip?: number },
32333233
): (limit: number) => Promise<GitReflog> {
32343234
return async (limit: number | undefined) => {
32353235
limit = limit ?? configuration.get('advanced.maxSearchItems') ?? 0;

src/git/gitProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export interface GitProvider extends Disposable {
266266
cursor?: string | undefined;
267267
limit?: number | undefined;
268268
merges?: boolean | undefined;
269-
ordering?: string | null | undefined;
269+
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
270270
ref?: string | undefined;
271271
since?: string | undefined;
272272
},
@@ -278,7 +278,7 @@ export interface GitProvider extends Disposable {
278278
cursor?: string | undefined;
279279
limit?: number | undefined;
280280
merges?: boolean | undefined;
281-
ordering?: string | null | undefined;
281+
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
282282
ref?: string | undefined;
283283
since?: string | undefined;
284284
},
@@ -300,7 +300,7 @@ export interface GitProvider extends Disposable {
300300
cursor?: string | undefined;
301301
force?: boolean | undefined;
302302
limit?: number | undefined;
303-
ordering?: string | null | undefined;
303+
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
304304
range?: Range | undefined;
305305
ref?: string | undefined;
306306
renames?: boolean | undefined;
@@ -343,7 +343,7 @@ export interface GitProvider extends Disposable {
343343
all?: boolean | undefined;
344344
branch?: string | undefined;
345345
limit?: number | undefined;
346-
ordering?: string | null | undefined;
346+
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
347347
skip?: number | undefined;
348348
},
349349
): Promise<GitReflog | undefined>;

src/git/gitProviderService.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ export class GitProviderService implements Disposable {
14041404
authors?: GitUser[];
14051405
limit?: number;
14061406
merges?: boolean;
1407-
ordering?: string | null;
1407+
ordering?: 'date' | 'author-date' | 'topo' | null;
14081408
ref?: string;
14091409
since?: string;
14101410
},
@@ -1420,7 +1420,7 @@ export class GitProviderService implements Disposable {
14201420
authors?: GitUser[];
14211421
limit?: number;
14221422
merges?: boolean;
1423-
ordering?: string | null;
1423+
ordering?: 'date' | 'author-date' | 'topo' | null;
14241424
ref?: string;
14251425
since?: string;
14261426
},
@@ -1447,7 +1447,7 @@ export class GitProviderService implements Disposable {
14471447
all?: boolean;
14481448
force?: boolean;
14491449
limit?: number;
1450-
ordering?: string | null;
1450+
ordering?: 'date' | 'author-date' | 'topo' | null;
14511451
range?: Range;
14521452
ref?: string;
14531453
renames?: boolean;
@@ -1634,7 +1634,13 @@ export class GitProviderService implements Disposable {
16341634
@log()
16351635
async getIncomingActivity(
16361636
repoPath: string | Uri,
1637-
options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
1637+
options?: {
1638+
all?: boolean;
1639+
branch?: string;
1640+
limit?: number;
1641+
ordering?: 'date' | 'author-date' | 'topo' | null;
1642+
skip?: number;
1643+
},
16381644
): Promise<GitReflog | undefined> {
16391645
const { provider, path } = this.getProvider(repoPath);
16401646
return provider.getIncomingActivity(path, options);

src/plus/github/githubGitProvider.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
11811181
cursor?: string;
11821182
limit?: number;
11831183
merges?: boolean;
1184-
ordering?: string | null;
1184+
ordering?: 'date' | 'author-date' | 'topo' | null;
11851185
ref?: string;
11861186
since?: string;
11871187
},
@@ -1286,7 +1286,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
12861286
cursor?: string;
12871287
limit?: number;
12881288
merges?: boolean;
1289-
ordering?: string | null;
1289+
ordering?: 'date' | 'author-date' | 'topo' | null;
12901290
ref?: string;
12911291
since?: string;
12921292
},
@@ -1304,7 +1304,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
13041304
authors?: GitUser[];
13051305
limit?: number;
13061306
merges?: boolean;
1307-
ordering?: string | null;
1307+
ordering?: 'date' | 'author-date' | 'topo' | null;
13081308
ref?: string;
13091309
},
13101310
): (limit: number | { until: string } | undefined) => Promise<GitLog> {
@@ -1572,7 +1572,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
15721572
cursor?: string;
15731573
force?: boolean | undefined;
15741574
limit?: number;
1575-
ordering?: string | null;
1575+
ordering?: 'date' | 'author-date' | 'topo' | null;
15761576
range?: Range;
15771577
ref?: string;
15781578
renames?: boolean;
@@ -1732,7 +1732,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
17321732
all?: boolean;
17331733
cursor?: string;
17341734
limit?: number;
1735-
ordering?: string | null;
1735+
ordering?: 'date' | 'author-date' | 'topo' | null;
17361736
range?: Range;
17371737
ref?: string;
17381738
renames?: boolean;
@@ -1870,7 +1870,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
18701870
options?: {
18711871
all?: boolean;
18721872
limit?: number;
1873-
ordering?: string | null;
1873+
ordering?: 'date' | 'author-date' | 'topo' | null;
18741874
range?: Range;
18751875
ref?: string;
18761876
renames?: boolean;
@@ -2133,7 +2133,13 @@ export class GitHubGitProvider implements GitProvider, Disposable {
21332133
@log()
21342134
async getIncomingActivity(
21352135
_repoPath: string,
2136-
_options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
2136+
_options?: {
2137+
all?: boolean;
2138+
branch?: string;
2139+
limit?: number;
2140+
ordering?: 'date' | 'author-date' | 'topo' | null;
2141+
skip?: number;
2142+
},
21372143
): Promise<GitReflog | undefined> {
21382144
return undefined;
21392145
}

0 commit comments

Comments
 (0)