提交 3a8c5531 编写于 作者: J Joao Moreno

💄

上级 7d89faae
......@@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
import { matchesContiguousSubString } from 'vs/base/common/filters';
import { TPromise } from 'vs/base/common/winjs.base';
import Severity from 'vs/base/common/severity';
import { IGitService, RefType, IRef, isValidBranchName, correctBranchName } from 'vs/workbench/parts/git/common/git';
import { IGitService, RefType, IRef } from 'vs/workbench/parts/git/common/git';
import { ICommand, CommandQuickOpenHandler } from 'vs/workbench/browser/quickopen';
import { Mode } from 'vs/base/parts/quickopen/common/quickOpen';
import { QuickOpenEntry, IHighlight, IContext, QuickOpenEntryGroup } from 'vs/base/parts/quickopen/browser/quickOpenModel';
......@@ -103,7 +103,9 @@ class BranchEntry extends QuickOpenEntry {
this.gitService = gitService;
this.messageService = messageService;
this.name = name;
// sanitize name
this.name = name.replace(/^\.|\/\.|\.\.|~|\^|:|\/$|\.lock$|\.lock\/|\\|\*|\s|^\s*$|\.$/g, '-');
}
getIcon(): string { return 'git'; }
......@@ -191,9 +193,6 @@ class CheckoutCommand implements ICommand {
entries.unshift(new CurrentHeadEntry(this.gitService, this.messageService, currentHeadMatches[0].head, currentHeadMatches[0].highlights));
} else if (exactMatches.length === 0 && input) {
if (!isValidBranchName(input)) {
input = correctBranchName(input);
}
const branchEntry = new BranchEntry(this.gitService, this.messageService, input);
entries.push(new QuickOpenEntryGroup(branchEntry, 'branch', checkoutEntries.length > 0 || remoteHeadEntries.length > 0));
}
......@@ -222,10 +221,6 @@ class BranchCommand implements ICommand {
return TPromise.as([]);
}
if (!isValidBranchName(input)) {
input = correctBranchName(input);
}
const gitModel = this.gitService.getModel();
const currentHead = gitModel.getHEAD();
......
......@@ -336,13 +336,4 @@ export interface IGitService extends IEventEmitter {
export interface IAskpassService {
askpass(id: string, host: string, command: string): TPromise<ICredentials>;
}
// Utils
const invalidBranchPatternName = /^\.|\/\.|\.\.|~|\^|:|\/$|\.lock$|\.lock\/|\\|\*|\s|^\s*$|\.$/g;
export function isValidBranchName(value: string): boolean {
return !invalidBranchPatternName.test(value);
}
export function correctBranchName(branchName: string): string {
return branchName.replace(invalidBranchPatternName, '-');
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册