diff --git a/src/git/gitService.ts b/src/git/gitService.ts index 3f8c5db..5442826 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -1654,26 +1654,15 @@ export class GitService implements Disposable { remote = remote ?? 'origin'; try { - const data = await Git.symbolic_ref(repoPath, `refs/remotes/${remote}/HEAD`); + const data = await Git.ls_remote__HEAD(repoPath, remote); if (data == null) return undefined; - return data.trim().substr(`${remote}/`.length); - } catch (ex) { - if (/is not a symbolic ref/.test(ex.stderr)) { - try { - const data = await Git.ls_remote__HEAD(repoPath, remote); - if (data == null) return undefined; - - const match = /ref:\s(\S+)\s+HEAD/m.exec(data); - if (match == null) return undefined; - - const [, branch] = match; - return branch.substr('refs/heads/'.length); - } catch { - return undefined; - } - } + const match = /ref:\s(\S+)\s+HEAD/m.exec(data); + if (match == null) return undefined; + const [, branch] = match; + return branch.substr('refs/heads/'.length); + } catch { return undefined; } } diff --git a/src/quickpicks/remoteProviderPicker.ts b/src/quickpicks/remoteProviderPicker.ts index b831c6c..fe53a96 100644 --- a/src/quickpicks/remoteProviderPicker.ts +++ b/src/quickpicks/remoteProviderPicker.ts @@ -50,9 +50,12 @@ export class CopyOrOpenRemoteCommandQuickPickItem extends CommandQuickPickItem { } } else if (resource.type === RemoteResourceType.CreatePullRequest) { let branch = resource.base.branch; - if (branch == null && this.remote.provider.hasApi()) { - const defaultBranch = await this.remote.provider.getDefaultBranch?.(); - branch = defaultBranch?.name; + if (branch == null) { + branch = await Container.git.getDefaultBranchName(this.remote.repoPath, this.remote.name); + if (branch == null && this.remote.provider.hasApi()) { + const defaultBranch = await this.remote.provider.getDefaultBranch?.(); + branch = defaultBranch?.name; + } } resource = {