Browse Source

Fixes getRemote to return any remote

Adds getRemoteWithProvider
main
Eric Amodio 2 years ago
parent
commit
ecc32a6bef
3 changed files with 15 additions and 3 deletions
  1. +1
    -1
      src/git/gitProviderService.ts
  2. +13
    -1
      src/git/models/branch.ts
  3. +1
    -1
      src/views/nodes/viewNode.ts

+ 1
- 1
src/git/gitProviderService.ts View File

@ -1527,7 +1527,7 @@ export class GitProviderService implements Disposable {
async getPullRequestForBranch(
branch: string,
remote: GitRemote,
remote: GitRemote<RemoteProvider | RichRemoteProvider>,
options?: { avatarSize?: number; include?: PullRequestState[]; limit?: number; timeout?: number },
): Promise<PullRequest | undefined>;
async getPullRequestForBranch(

+ 13
- 1
src/git/models/branch.ts View File

@ -5,6 +5,7 @@ import { debug } from '../../system/decorators/log';
import { memoize } from '../../system/decorators/memoize';
import { cancellable } from '../../system/promise';
import { sortCompare } from '../../system/string';
import type { RemoteProvider, RichRemoteProvider } from '../remotes/provider';
import type { PullRequest, PullRequestState } from './pullRequest';
import type { GitBranchReference, GitReference } from './reference';
import { GitRevision } from './reference';
@ -100,7 +101,7 @@ export class GitBranch implements GitBranchReference {
}): Promise<PullRequest | undefined> {
if (this._pullRequest == null) {
async function getCore(this: GitBranch): Promise<PullRequest | undefined> {
const remote = await this.getRemote();
const remote = await this.getRemoteWithProvider();
if (remote == null) return undefined;
const branch = this.getTrackingWithoutRemote() ?? this.getNameWithoutRemote();
@ -134,6 +135,17 @@ export class GitBranch implements GitBranchReference {
const remoteName = this.getRemoteName();
if (remoteName == null) return undefined;
const remotes = await Container.instance.git.getRemotes(this.repoPath);
if (remotes.length === 0) return undefined;
return remotes.find(r => r.name === remoteName);
}
@memoize()
async getRemoteWithProvider(): Promise<GitRemote<RemoteProvider | RichRemoteProvider> | undefined> {
const remoteName = this.getRemoteName();
if (remoteName == null) return undefined;
const remotes = await Container.instance.git.getRemotesWithProviders(this.repoPath);
if (remotes.length === 0) return undefined;

+ 1
- 1
src/views/nodes/viewNode.ts View File

@ -434,7 +434,7 @@ export abstract class RepositoryFolderNode<
);
providerName = providers?.length ? providers[0].name : undefined;
} else {
const remote = await branch.getRemote();
const remote = await branch.getRemoteWithProvider();
providerName = remote?.provider?.name;
}

Loading…
Cancel
Save