ogit
Version:
A lazy developer's Git CLI made simple. Makes using git on cloud IDEs (i.e. C9) a walk in the park.
61 lines (60 loc) • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const AbstractBranchCommand_1 = require("../abstracts/AbstractBranchCommand");
const inquirer = require("inquirer");
const command_1 = require("@oclif/command");
const git_1 = require("../wrapper/git");
class RenameBranchCommand extends AbstractBranchCommand_1.default {
getSelectedBranch() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { flags } = this.parse(RenameBranchCommand);
const answers = yield inquirer.prompt([
{
message: flags.search
? 'Name of the branch to rename'
: 'Select the branch to rename',
type: flags.search ? 'autocomplete' : 'list',
default: yield git_1.GitFacade.getCurrentBranchName(),
source: this.searchLocalBranches,
choices: this.localBranches,
name: 'localBranchName',
validate(choices) {
return choices.length > 0;
}
},
{
message: 'Please enter the new name of the branch',
type: 'input',
name: 'newBranchName',
validate(name) {
return name.length > 0;
}
}
]);
return {
branchNameA: answers.localBranchName,
branchNameB: answers.newBranchName
};
});
}
preformBranchOperation(branchInfo) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield git_1.GitFacade.renameBranch(branchInfo.branchNameA, branchInfo.branchNameB);
});
}
run() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.runHelper();
});
}
requireRemoteBranches() {
return false;
}
}
RenameBranchCommand.description = 'Renames a local branch to a new one';
RenameBranchCommand.flags = {
// can search --search or -s
search: command_1.flags.boolean({ char: 's' })
};
exports.default = RenameBranchCommand;