Sfoglia il codice sorgente

Adds type safety to date ordering

main
Eric Amodio 2 anni fa
parent
commit
b0b014c14f
5 ha cambiato i file con 50 aggiunte e 32 eliminazioni
  1. +15
    -9
      src/env/node/git/git.ts
  2. +8
    -8
      src/env/node/git/localGitProvider.ts
  3. +4
    -4
      src/git/gitProvider.ts
  4. +10
    -4
      src/git/gitProviderService.ts
  5. +13
    -7
      src/plus/github/githubGitProvider.ts

+ 15
- 9
src/env/node/git/git.ts Vedi File

@ -705,7 +705,7 @@ export class Git {
authors?: GitUser[]; authors?: GitUser[];
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
similarityThreshold?: number | null; similarityThreshold?: number | null;
since?: number | string; since?: number | string;
until?: number | string; until?: number | string;
@ -796,7 +796,7 @@ export class Git {
filters?: GitDiffFilter[]; filters?: GitDiffFilter[];
firstParent?: boolean; firstParent?: boolean;
limit?: number; limit?: number;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
renames?: boolean; renames?: boolean;
reverse?: boolean; reverse?: boolean;
since?: string; since?: string;
@ -890,7 +890,7 @@ export class Git {
repoPath: string, repoPath: string,
fileName: string, fileName: string,
options?: { options?: {
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
similarityThreshold?: number | null; similarityThreshold?: number | null;
cancellation?: CancellationToken; cancellation?: CancellationToken;
@ -929,7 +929,7 @@ export class Git {
repoPath: string, repoPath: string,
objectId: string, objectId: string,
ref: string, ref: string,
ordering: string | null,
ordering: 'date' | 'author-date' | 'topo' | null,
file?: string, file?: string,
cancellation?: CancellationToken, cancellation?: CancellationToken,
) { ) {
@ -955,7 +955,7 @@ export class Git {
return data.length === 0 ? undefined : data.trim(); return data.length === 0 ? undefined : data.trim();
} }
async log__recent(repoPath: string, ordering?: string | null) {
async log__recent(repoPath: string, ordering?: 'date' | 'author-date' | 'topo' | null) {
const params = ['log', '-n1', '--format=%H']; const params = ['log', '-n1', '--format=%H'];
if (ordering) { if (ordering) {
@ -971,7 +971,7 @@ export class Git {
return data.length === 0 ? undefined : data.trim(); return data.length === 0 ? undefined : data.trim();
} }
async log__recent_committerdate(repoPath: string, ordering?: string | null) {
async log__recent_committerdate(repoPath: string, ordering?: 'date' | 'author-date' | 'topo' | null) {
const params = ['log', '-n1', '--format=%ct']; const params = ['log', '-n1', '--format=%ct'];
if (ordering) { if (ordering) {
@ -995,7 +995,7 @@ export class Git {
ordering, ordering,
skip, skip,
useShow, useShow,
}: { limit?: number; ordering?: string | null; skip?: number; useShow?: boolean } = {},
}: { limit?: number; ordering?: 'date' | 'author-date' | 'topo' | null; skip?: number; useShow?: boolean } = {},
) { ) {
const params = [ const params = [
useShow ? 'show' : 'log', useShow ? 'show' : 'log',
@ -1096,7 +1096,13 @@ export class Git {
limit, limit,
ordering, ordering,
skip, skip,
}: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number } = {},
}: {
all?: boolean;
branch?: string;
limit?: number;
ordering?: 'date' | 'author-date' | 'topo' | null;
skip?: number;
} = {},
): Promise<string> { ): Promise<string> {
const params = ['log', '--walk-reflogs', `--format=${GitReflogParser.defaultFormat}`, '--date=iso8601']; const params = ['log', '--walk-reflogs', `--format=${GitReflogParser.defaultFormat}`, '--date=iso8601'];
@ -1188,7 +1194,7 @@ export class Git {
async rev_parse__currentBranch( async rev_parse__currentBranch(
repoPath: string, repoPath: string,
ordering: string | null,
ordering: 'date' | 'author-date' | 'topo' | null,
): Promise<[string, string | undefined] | undefined> { ): Promise<[string, string | undefined] | undefined> {
try { try {
const data = await this.git<string>( const data = await this.git<string>(

+ 8
- 8
src/env/node/git/localGitProvider.ts Vedi File

@ -2064,7 +2064,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
cursor?: string; cursor?: string;
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
since?: number | string; since?: number | string;
until?: number | string; until?: number | string;
@ -2148,7 +2148,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
cursor?: string; cursor?: string;
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
since?: string; since?: string;
}, },
@ -2186,7 +2186,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
authors?: GitUser[]; authors?: GitUser[];
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
}, },
): (limit: number | { until: string } | undefined) => Promise<GitLog> { ): (limit: number | { until: string } | undefined) => Promise<GitLog> {
@ -2423,7 +2423,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
cursor?: string; cursor?: string;
force?: boolean | undefined; force?: boolean | undefined;
limit?: number; limit?: number;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
range?: Range; range?: Range;
ref?: string; ref?: string;
renames?: boolean; renames?: boolean;
@ -2576,7 +2576,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
all?: boolean; all?: boolean;
cursor?: string; cursor?: string;
limit?: number; limit?: number;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
range?: Range; range?: Range;
ref?: string; ref?: string;
renames?: boolean; renames?: boolean;
@ -2657,7 +2657,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
options: { options: {
all?: boolean; all?: boolean;
limit?: number; limit?: number;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
range?: Range; range?: Range;
ref?: string; ref?: string;
renames?: boolean; renames?: boolean;
@ -3201,7 +3201,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
@log() @log()
async getIncomingActivity( async getIncomingActivity(
repoPath: string, repoPath: string,
options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
options?: { all?: boolean; branch?: string; limit?: number; ordering?: 'date' | 'author-date' | 'topo' | null; skip?: number },
): Promise<GitReflog | undefined> { ): Promise<GitReflog | undefined> {
const scope = getLogScope(); const scope = getLogScope();
@ -3229,7 +3229,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
private getReflogMoreFn( private getReflogMoreFn(
reflog: GitReflog, reflog: GitReflog,
options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
options?: { all?: boolean; branch?: string; limit?: number; ordering?: 'date' | 'author-date' | 'topo' | null; skip?: number },
): (limit: number) => Promise<GitReflog> { ): (limit: number) => Promise<GitReflog> {
return async (limit: number | undefined) => { return async (limit: number | undefined) => {
limit = limit ?? configuration.get('advanced.maxSearchItems') ?? 0; limit = limit ?? configuration.get('advanced.maxSearchItems') ?? 0;

+ 4
- 4
src/git/gitProvider.ts Vedi File

@ -266,7 +266,7 @@ export interface GitProvider extends Disposable {
cursor?: string | undefined; cursor?: string | undefined;
limit?: number | undefined; limit?: number | undefined;
merges?: boolean | undefined; merges?: boolean | undefined;
ordering?: string | null | undefined;
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
ref?: string | undefined; ref?: string | undefined;
since?: string | undefined; since?: string | undefined;
}, },
@ -278,7 +278,7 @@ export interface GitProvider extends Disposable {
cursor?: string | undefined; cursor?: string | undefined;
limit?: number | undefined; limit?: number | undefined;
merges?: boolean | undefined; merges?: boolean | undefined;
ordering?: string | null | undefined;
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
ref?: string | undefined; ref?: string | undefined;
since?: string | undefined; since?: string | undefined;
}, },
@ -300,7 +300,7 @@ export interface GitProvider extends Disposable {
cursor?: string | undefined; cursor?: string | undefined;
force?: boolean | undefined; force?: boolean | undefined;
limit?: number | undefined; limit?: number | undefined;
ordering?: string | null | undefined;
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
range?: Range | undefined; range?: Range | undefined;
ref?: string | undefined; ref?: string | undefined;
renames?: boolean | undefined; renames?: boolean | undefined;
@ -343,7 +343,7 @@ export interface GitProvider extends Disposable {
all?: boolean | undefined; all?: boolean | undefined;
branch?: string | undefined; branch?: string | undefined;
limit?: number | undefined; limit?: number | undefined;
ordering?: string | null | undefined;
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
skip?: number | undefined; skip?: number | undefined;
}, },
): Promise<GitReflog | undefined>; ): Promise<GitReflog | undefined>;

+ 10
- 4
src/git/gitProviderService.ts Vedi File

@ -1404,7 +1404,7 @@ export class GitProviderService implements Disposable {
authors?: GitUser[]; authors?: GitUser[];
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
since?: string; since?: string;
}, },
@ -1420,7 +1420,7 @@ export class GitProviderService implements Disposable {
authors?: GitUser[]; authors?: GitUser[];
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
since?: string; since?: string;
}, },
@ -1447,7 +1447,7 @@ export class GitProviderService implements Disposable {
all?: boolean; all?: boolean;
force?: boolean; force?: boolean;
limit?: number; limit?: number;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
range?: Range; range?: Range;
ref?: string; ref?: string;
renames?: boolean; renames?: boolean;
@ -1634,7 +1634,13 @@ export class GitProviderService implements Disposable {
@log() @log()
async getIncomingActivity( async getIncomingActivity(
repoPath: string | Uri, repoPath: string | Uri,
options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
options?: {
all?: boolean;
branch?: string;
limit?: number;
ordering?: 'date' | 'author-date' | 'topo' | null;
skip?: number;
},
): Promise<GitReflog | undefined> { ): Promise<GitReflog | undefined> {
const { provider, path } = this.getProvider(repoPath); const { provider, path } = this.getProvider(repoPath);
return provider.getIncomingActivity(path, options); return provider.getIncomingActivity(path, options);

+ 13
- 7
src/plus/github/githubGitProvider.ts Vedi File

@ -1181,7 +1181,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
cursor?: string; cursor?: string;
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
since?: string; since?: string;
}, },
@ -1286,7 +1286,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
cursor?: string; cursor?: string;
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
since?: string; since?: string;
}, },
@ -1304,7 +1304,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
authors?: GitUser[]; authors?: GitUser[];
limit?: number; limit?: number;
merges?: boolean; merges?: boolean;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
ref?: string; ref?: string;
}, },
): (limit: number | { until: string } | undefined) => Promise<GitLog> { ): (limit: number | { until: string } | undefined) => Promise<GitLog> {
@ -1572,7 +1572,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
cursor?: string; cursor?: string;
force?: boolean | undefined; force?: boolean | undefined;
limit?: number; limit?: number;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
range?: Range; range?: Range;
ref?: string; ref?: string;
renames?: boolean; renames?: boolean;
@ -1732,7 +1732,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
all?: boolean; all?: boolean;
cursor?: string; cursor?: string;
limit?: number; limit?: number;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
range?: Range; range?: Range;
ref?: string; ref?: string;
renames?: boolean; renames?: boolean;
@ -1870,7 +1870,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
options?: { options?: {
all?: boolean; all?: boolean;
limit?: number; limit?: number;
ordering?: string | null;
ordering?: 'date' | 'author-date' | 'topo' | null;
range?: Range; range?: Range;
ref?: string; ref?: string;
renames?: boolean; renames?: boolean;
@ -2133,7 +2133,13 @@ export class GitHubGitProvider implements GitProvider, Disposable {
@log() @log()
async getIncomingActivity( async getIncomingActivity(
_repoPath: string, _repoPath: string,
_options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
_options?: {
all?: boolean;
branch?: string;
limit?: number;
ordering?: 'date' | 'author-date' | 'topo' | null;
skip?: number;
},
): Promise<GitReflog | undefined> { ): Promise<GitReflog | undefined> {
return undefined; return undefined;
} }

Caricamento…
Annulla
Salva