Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to exclude items from Git branch checkout list #13506 #16792

Merged
merged 2 commits into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 includeRemotes = 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 = includeRemotes ? 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