Ver a proveniência

Avoids default options

main
Eric Amodio há 2 anos
ascendente
cometimento
2bdf73d7c3
1 ficheiros alterados com 13 adições e 11 eliminações
  1. +13
    -11
      src/git/gitProviderService.ts

+ 13
- 11
src/git/gitProviderService.ts Ver ficheiro

@ -1288,20 +1288,17 @@ export class GitProviderService implements Disposable {
provider: RichRemoteProvider,
options?: { avatarSize?: number; include?: PullRequestState[]; limit?: number; timeout?: number },
): Promise<PullRequest | undefined>;
@gate<GitProviderService['getPullRequestForBranch']>((ref, remoteOrProvider, options) => {
@gate<GitProviderService['getPullRequestForBranch']>((branch, remoteOrProvider, options) => {
const provider = GitRemote.is(remoteOrProvider) ? remoteOrProvider.provider : remoteOrProvider;
return `${ref}${provider != null ? `|${provideran>class="p">.id}:${provider.domain}/${provider.path}` : ''}${
options != null ? `|${options.limit ?? -1}:${options.include?.join(',')}` : ''
}`;
return `${branch}${
provider != null ? `|${provider.id}:${provider.domain}/${provider.path}` : ''
}|${JSON.stringify(options)}`;
})
@debug<GitProviderService['getPullRequestForBranch']>({ args: { 1: remoteOrProvider => remoteOrProvider.name } })
async getPullRequestForBranch(
branch: string,
remoteOrProvider: GitRemote | RichRemoteProvider,
{
timeout,
...options
}: { avatarSize?: number; include?: PullRequestState[]; limit?: number; timeout?: number } = {},
options?: { avatarSize?: number; include?: PullRequestState[]; limit?: number; timeout?: number },
): Promise<PullRequest | undefined> {
let provider;
if (GitRemote.is(remoteOrProvider)) {
@ -1311,6 +1308,11 @@ export class GitProviderService implements Disposable {
provider = remoteOrProvider;
}
let timeout;
if (options != null) {
({ timeout, ...options } = options);
}
let promiseOrPR = provider.getPullRequestForBranch(branch, options);
if (promiseOrPR == null || !Promises.is(promiseOrPR)) {
return promiseOrPR;
@ -1351,7 +1353,7 @@ export class GitProviderService implements Disposable {
async getPullRequestForCommit(
ref: string,
remoteOrProvider: GitRemote | RichRemoteProvider,
{ timeout }: { timeout?: number } = {},
options?: { timeout?: number },
): Promise<PullRequest | undefined> {
if (GitRevision.isUncommitted(ref)) return undefined;
@ -1368,8 +1370,8 @@ export class GitProviderService implements Disposable {
return promiseOrPR;
}
if (timeout != null && timeout > 0) {
promiseOrPR = Promises.cancellable(promiseOrPR, timeout);
if (options?.timeout != null && options.timeout > 0) {
promiseOrPR = Promises.cancellable(promiseOrPR, options.timeout);
}
try {

Carregando…
Cancelar
Guardar