提交 133e9990 编写于 作者: J Joao Moreno

💄

上级 cf107f3c
...@@ -240,11 +240,6 @@ ...@@ -240,11 +240,6 @@
"title": "%command.branch%", "title": "%command.branch%",
"category": "Git" "category": "Git"
}, },
{
"command": "git.branchFrom",
"title": "%command.branchFrom%",
"category": "Git"
},
{ {
"command": "git.deleteBranch", "command": "git.deleteBranch",
"title": "%command.deleteBranch%", "title": "%command.deleteBranch%",
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
"command.undoCommit": "Undo Last Commit", "command.undoCommit": "Undo Last Commit",
"command.checkout": "Checkout to...", "command.checkout": "Checkout to...",
"command.branch": "Create Branch...", "command.branch": "Create Branch...",
"command.branchFrom": "Create Branch From...",
"command.deleteBranch": "Delete Branch...", "command.deleteBranch": "Delete Branch...",
"command.renameBranch": "Rename Branch...", "command.renameBranch": "Rename Branch...",
"command.merge": "Merge Branch...", "command.merge": "Merge Branch...",
......
...@@ -103,6 +103,15 @@ class CreateBranchItem implements QuickPickItem { ...@@ -103,6 +103,15 @@ class CreateBranchItem implements QuickPickItem {
} }
} }
class HEADItem implements QuickPickItem {
constructor(private repository: Repository) { }
get label(): string { return 'HEAD'; }
get description(): string { return (this.repository.HEAD && this.repository.HEAD.commit || '').substr(0, 8); }
get alwaysShow(): boolean { return true; }
}
interface CommandOptions { interface CommandOptions {
repository?: boolean; repository?: boolean;
diff?: boolean; diff?: boolean;
...@@ -154,7 +163,7 @@ async function categorizeResourceByResolution(resources: Resource[]): Promise<{ ...@@ -154,7 +163,7 @@ async function categorizeResourceByResolution(resources: Resource[]): Promise<{
return { merge, resolved, unresolved, deletionConflicts }; return { merge, resolved, unresolved, deletionConflicts };
} }
function repositoryRefsToItems(repository: Repository): Array<CheckoutItem> { function createCheckoutItems(repository: Repository): CheckoutItem[] {
const config = workspace.getConfiguration('git'); const config = workspace.getConfiguration('git');
const checkoutType = config.get<string>('checkoutType') || 'all'; const checkoutType = config.get<string>('checkoutType') || 'all';
const includeTags = checkoutType === 'all' || checkoutType === 'tags'; const includeTags = checkoutType === 'all' || checkoutType === 'tags';
...@@ -170,7 +179,7 @@ function repositoryRefsToItems(repository: Repository): Array<CheckoutItem> { ...@@ -170,7 +179,7 @@ function repositoryRefsToItems(repository: Repository): Array<CheckoutItem> {
return [...heads, ...tags, ...remoteHeads]; return [...heads, ...tags, ...remoteHeads];
} }
async function inputNameForBranch(): Promise<string> { async function getBranchNameFromUser(): Promise<string> {
const config = workspace.getConfiguration('git'); const config = workspace.getConfiguration('git');
const branchWhitespaceChar = config.get<string>('branchWhitespaceChar')!; const branchWhitespaceChar = config.get<string>('branchWhitespaceChar')!;
const branchValidationRegex = config.get<string>('branchValidationRegex')!; const branchValidationRegex = config.get<string>('branchValidationRegex')!;
...@@ -1437,7 +1446,7 @@ export class CommandCenter { ...@@ -1437,7 +1446,7 @@ export class CommandCenter {
} }
const createBranch = new CreateBranchItem(this); const createBranch = new CreateBranchItem(this);
const picks = [createBranch, ...repositoryRefsToItems(repository)]; const picks = [createBranch, ...createCheckoutItems(repository)];
const placeHolder = localize('select a ref to checkout', 'Select a ref to checkout'); const placeHolder = localize('select a ref to checkout', 'Select a ref to checkout');
const choice = await window.showQuickPick(picks, { placeHolder }); const choice = await window.showQuickPick(picks, { placeHolder });
...@@ -1450,27 +1459,22 @@ export class CommandCenter { ...@@ -1450,27 +1459,22 @@ export class CommandCenter {
} }
@command('git.branch', { repository: true }) @command('git.branch', { repository: true })
async branch(repository: Repository, ref?: string): Promise<void> { async branch(repository: Repository): Promise<void> {
const name = await inputNameForBranch(); const picks = [new HEADItem(repository), ...createCheckoutItems(repository)];
const placeHolder = localize('select a ref to create a new branch from', 'Select a ref to create a new branch from');
const target = await window.showQuickPick(picks, { placeHolder });
if (!name) { if (!target) {
return; return;
} }
await repository.branch(name, true, ref); const name = await getBranchNameFromUser();
}
@command('git.branchFrom', { repository: true })
async createBranchFrom(repository: Repository): Promise<void> {
const refs = repositoryRefsToItems(repository);
const placeHolder = localize('select a ref to create a new branch from', 'Select a ref to create a new branch from');
const choice = await window.showQuickPick(refs, { placeHolder });
if (!choice) { if (!name) {
return; return;
} }
await this.branch(repository, choice.label); await repository.branch(name, true, target.label);
} }
@command('git.deleteBranch', { repository: true }) @command('git.deleteBranch', { repository: true })
...@@ -2010,7 +2014,7 @@ export class CommandCenter { ...@@ -2010,7 +2014,7 @@ export class CommandCenter {
return Promise.resolve(); return Promise.resolve();
} }
return Promise.resolve(method.apply(this, [repository, ...args.slice(1)])); return Promise.resolve(method.apply(this, [repository, ...args]));
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册