浏览代码

Fixes default branch lookup

main
Eric Amodio 3 年前
父节点
当前提交
6f7fc115f0
共有 2 个文件被更改,包括 12 次插入20 次删除
  1. +6
    -17
      src/git/gitService.ts
  2. +6
    -3
      src/quickpicks/remoteProviderPicker.ts

+ 6
- 17
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;
}
}

+ 6
- 3
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 = {

正在加载...
取消
保存