Skip to content

Commit

Permalink
Highlight branchs upstream if defined by placing item first in picker
Browse files Browse the repository at this point in the history
  • Loading branch information
tomerstav committed Oct 23, 2020
1 parent 7b93698 commit 039f26d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1869,14 +1869,16 @@ export class CommandCenter {
const includeRemotes = checkoutType === 'all' || checkoutType === 'remote';

const heads = repository.refs.filter(ref => ref.type === RefType.Head)
.filter(ref => ref.name || ref.commit)
.map(ref => new RebaseItem(ref as Branch));
.filter(ref => ref.name || ref.commit);

const remoteHeads = (includeRemotes ? repository.refs.filter(ref => ref.type === RefType.RemoteHead) : [])
.filter(ref => ref.name || ref.commit)
.map(ref => new RebaseItem(ref as Branch));
.filter(ref => ref.name || ref.commit);

// set upstream branch as first
const upstreamName = repository?.HEAD?.upstream?.name;
const upstreamRemote = repository?.HEAD?.upstream?.remote;
const picks = [...heads, ...remoteHeads].sort(ref => ref.name === `${upstreamRemote}/${upstreamName}` && ref.remote === upstreamRemote ? -1 : 0).map(ref => new RebaseItem(ref as Branch));

const picks = [...heads, ...remoteHeads];
const placeHolder = localize('select a branch to rebase onto', 'Select a branch to rebase onto');
const choice = await window.showQuickPick<RebaseItem>(picks, { placeHolder });

Expand Down

0 comments on commit 039f26d

Please sign in to comment.