UNPKG

ogit

Version:

A lazy developer's Git CLI made simple. Makes using git on cloud IDEs (i.e. C9) a walk in the park.

53 lines (52 loc) 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const AbstractBranchCommand_1 = require("../abstracts/AbstractBranchCommand"); const git_1 = require("../wrapper/git"); const inquirer = require("inquirer"); class CreateBranchCommand extends AbstractBranchCommand_1.default { run() { const _super = name => super[name]; return tslib_1.__awaiter(this, void 0, void 0, function* () { yield _super("runHelper").call(this); }); } getSelectedBranch() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const answers = yield inquirer.prompt([ { message: 'Select the local branch to switch to', type: 'list', choices: this.localBranches, name: 'localBranchName', validate(choices) { return choices.length > 0; } } ]); return { branchNameA: answers.localBranchName, branchNameB: undefined }; }); } preformBranchOperation(branchInfo) { return tslib_1.__awaiter(this, void 0, void 0, function* () { try { yield git_1.GitFacade.switchBranch(branchInfo.branchNameA); } catch (err) { console.error('Possible merge conflict with the following files:'); err.fileNamesArray.forEach((fileName) => { console.error(fileName.trim()); }); console.error('Please commit your changes (ogit commit-changes) or stash (ogit stash-changes) them before you switch branches'); } }); } requireRemoteBranches() { return false; } } CreateBranchCommand.description = 'Switches the current branch to another local branch'; exports.CreateBranchCommand = CreateBranchCommand;