Fixes getBranch when name is fully qualified

This commit is contained in:
Eric Amodio
2021-01-27 14:51:10 -05:00
parent ba428fe102
commit e6d5a20944

View File

@@ -1978,7 +1978,14 @@ export class Repository {
return this.getHEAD();
}
const result = await this.run(['for-each-ref', '--format=%(refname)%00%(upstream:short)%00%(upstream:track)%00%(objectname)', `refs/heads/${name}`, `refs/remotes/${name}`]);
const args = ['for-each-ref', '--format=%(refname)%00%(upstream:short)%00%(upstream:track)%00%(objectname)'];
if (/^refs\/(head|remotes)\//i.test(name)) {
args.push(name);
} else {
args.push(`refs/heads/${name}`, `refs/remotes/${name}`);
}
const result = await this.run(args);
const branches: Branch[] = result.stdout.trim().split('\n').map<Branch | undefined>(line => {
let [branchName, upstream, status, ref] = line.trim().split('\0');