Skip to content

Commit 5697b9a

Browse files
Crystal Tennlrotschy
andcommitted
If remote cannot find "origin", then automatically try to get the next remote regardless of name so that the user does not have to enter it manually.
Co-authored-by: Liela Rotschy <lrotschy@github.com>
1 parent 0ff1a03 commit 5697b9a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/git/repository.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,16 @@ export async function getGitHubUrls(): Promise<GitHubUrls[] | null> {
6666
logDebug("Find `origin` remote for repository", r.rootUri.path);
6767
await r.status();
6868

69-
const originRemote = r.state.remotes.filter(remote => remote.name === remoteName);
70-
if (originRemote.length > 0 && originRemote[0].pushUrl?.indexOf("github.com") !== -1) {
71-
const url = originRemote[0].pushUrl;
69+
// Try to get "origin" remote first
70+
let remote = r.state.remotes.filter(remote => remote.name === remoteName);
71+
72+
// If "origin" does not exist, automatically get another remote
73+
if (remote === undefined || remote.length === 0) {
74+
remote = [r.state.remotes[0]];
75+
}
76+
77+
if (remote.length > 0 && remote[0].pushUrl?.indexOf("github.com") !== -1) {
78+
const url = remote[0].pushUrl;
7279

7380
return {
7481
workspaceUri: r.rootUri,

0 commit comments

Comments
 (0)