提交 24c05ae2 编写于 作者: J Justin Horner

Implement rename branch command

上级 b3a977e3
......@@ -843,6 +843,44 @@ export class CommandCenter {
}
}
@command('git.renameBranch')
async renameBranch(): Promise<void> {
const placeHolder = localize('provide branch name', "Please provide a branch name");
const name = await window.showInputBox({ placeHolder });
if (!name || name.trim().length === 0) {
return;
}
const run = force => this.model.renameBranch(name);
try {
await run(name);
} catch (err) {
console.log(err);
if (err.gitErrorCode !== GitErrorCodes.InvalidBranchName &&
err.gitErrorCode !== GitErrorCodes.BranchAlreadyExists) {
return err;
}
let message = '';
switch (err.gitErrorCode) {
case GitErrorCodes.InvalidBranchName:
message = localize('invalid branch name', 'Invalid branch name');
break;
case GitErrorCodes.BranchAlreadyExists:
message = localize('branch already exists', `A branch named '${name}' already exists`);
break;
}
if (!message) {
return;
}
window.showErrorMessage(message);
}
}
@command('git.merge')
async merge(): Promise<void> {
const config = workspace.getConfiguration('git');
......
......@@ -213,9 +213,10 @@ export enum Operation {
Stage = 1 << 14,
GetCommitTemplate = 1 << 15,
DeleteBranch = 1 << 16,
Merge = 1 << 17,
Ignore = 1 << 18,
Tag = 1 << 19
RenameBranch = 1 << 17,
Merge = 1 << 18,
Ignore = 1 << 19,
Tag = 1 << 20
}
// function getOperationName(operation: Operation): string {
......@@ -463,6 +464,10 @@ export class Model implements Disposable {
await this.run(Operation.DeleteBranch, () => this.repository.deleteBranch(name, force));
}
async renameBranch(name: string): Promise<void> {
await this.run(Operation.RenameBranch, () => this.repository.renameBranch(name));
}
async merge(ref: string): Promise<void> {
await this.run(Operation.Merge, () => this.repository.merge(ref));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册