Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/github/folderRepositoryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,8 @@ export class FolderRepositoryManager extends Disposable {
}

const upstreamRef = branch ? branch.upstream : this.upstreamRef;
if (upstreamRef) {
// A remote of "." means the branch tracks another local branch.
if (upstreamRef && upstreamRef.remote !== '.') {
// If our current branch has an upstream ref set, find its GitHubRepository.
const upstream = this.findRepo(byRemoteName(upstreamRef.remote));

Expand Down
31 changes: 30 additions & 1 deletion src/test/github/folderRepositoryManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Protocol } from '../../common/protocol';
import { GitHubRepository } from '../../github/githubRepository';
import { PullRequestBuilder } from '../builders/rest/pullRequestBuilder';
import { convertRESTPullRequestToRawPullRequest } from '../../github/utils';
import { GitApiImpl } from '../../api/api1';
import { GitApiImpl, RefType } from '../../api/api1';
import { CredentialStore } from '../../github/credentials';
import { MockExtensionContext } from '../mocks/mockExtensionContext';
import { Uri } from 'vscode';
Expand Down Expand Up @@ -87,6 +87,35 @@ describe('PullRequestManager', function () {
});
});

describe('getPullRequestDefaults', function () {
it('uses a GitHub remote when the branch tracks a local sibling branch', async function () {
const url = 'https://github.com/owner/repo.git';
const remote = new GitHubRemote('origin', url, new Protocol(url), GitHubServerType.GitHubDotCom);
const githubRepository = new GitHubRepository(1, remote, repository.rootUri, manager.credentialStore, telemetry);
(manager as any)._githubRepositories = [githubRepository];
sinon.stub(githubRepository, 'getMetadata').resolves({
owner: { login: 'owner' },
name: 'repo',
default_branch: 'main',
} as any);

const defaults = await manager.getPullRequestDefaults({
type: RefType.Head,
name: 'feature-b',
upstream: {
remote: '.',
name: 'feature-a',
},
});
Comment thread
alexr00 marked this conversation as resolved.

assert.deepStrictEqual(defaults, {
owner: 'owner',
repo: 'repo',
base: 'main',
});
});
});

describe('activePullRequest', function () {
it('gets and sets the active pull request', function () {
assert.strictEqual(manager.activePullRequest, undefined);
Expand Down