Skip to content

Commit

Permalink
Option to exclude items from Git branch checkout list #13506
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Patterson authored and Ryan Patterson committed Dec 7, 2016
1 parent 0d65ced commit d55c1df
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/vs/workbench/parts/git/browser/gitQuickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,16 @@ class CheckoutCommand implements ICommand {
getResults(input: string): TPromise<QuickOpenEntry[]> {
input = input.trim();

const checkoutType = this.gitService.checkoutType;
const includeTags = checkoutType === 'all' || checkoutType === 'tags';
const inclueRemotes = checkoutType === 'all' || checkoutType === 'remote';

const gitModel = this.gitService.getModel();
const currentHead = gitModel.getHEAD();
const refs = gitModel.getRefs();
const heads = refs.filter(ref => ref.type === RefType.Head);
const tags = refs.filter(ref => ref.type === RefType.Tag);
const remoteHeads = refs.filter(ref => ref.type === RefType.RemoteHead);
const tags = includeTags ? refs.filter(ref => ref.type === RefType.Tag) : [];
const remoteHeads = inclueRemotes ? refs.filter(ref => ref.type === RefType.RemoteHead) : [];

const headMatches = heads
.map(head => ({ head, highlights: matchesContiguousSubString(input, head.name) }))
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/parts/git/browser/gitServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ export class GitService extends EventEmitter
this.transition(ServiceState.OK);
}
}
get checkoutType(): string {
const { checkoutType } = this.configurationService.getConfiguration<IGitConfiguration>('git');
return checkoutType;
}

get onOutput(): Event<string> { return this.raw.onOutput; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ export function registerContributions(): void {
enum: ['all', 'tracked', 'off'],
default: 'all',
description: nls.localize('countBadge', "Controls the git badge counter."),
},
'git.checkoutType': {
type: 'string',
enum: ['all', 'local', 'tags', 'remote'],
default: 'all',
description: nls.localize('checkoutType', "Controls what type of branches are listed."),
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/parts/git/common/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export interface IGitConfiguration {
allowLargeRepositories: boolean;
confirmSync: boolean;
countBadge: string;
checkoutType: string;
}

// Service interfaces
Expand Down Expand Up @@ -305,6 +306,7 @@ export const IGitService = createDecorator<IGitService>(GIT_SERVICE_ID);
export interface IGitService extends IEventEmitter {
_serviceBrand: any;
allowHugeRepositories: boolean;
checkoutType: string;
onOutput: Event<string>;
status(): TPromise<IModel>;
init(): TPromise<IModel>;
Expand Down

0 comments on commit d55c1df

Please sign in to comment.