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.

45 lines (44 loc) 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const AbstractCommitCommand_1 = require("../abstracts/AbstractCommitCommand"); const git_1 = require("../wrapper/git"); class AmendLastCommand extends AbstractCommitCommand_1.default { run() { const _super = name => super[name]; return tslib_1.__awaiter(this, void 0, void 0, function* () { yield _super("runHelper").call(this); }); } getPrompts() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const lastCommitMessage = yield git_1.GitFacade.getLastCommitMessage(); return Promise.resolve([ { message: 'The following changes will be committed', type: 'checkbox', choices: this.choices, name: 'fileToBeCommitted', when: this.choices.length > 0 }, { message: 'Commit message', type: 'input', name: 'commitMessage', default: lastCommitMessage, validate(message) { return message !== ''; } } ]); }); } runCommit(message, fileNames) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const commitResult = yield git_1.GitFacade.ammendLastCommit(fileNames, message); console.log(`Amend commit ${commitResult.commit} for branch ${commitResult.branch} was successful with ${commitResult.summary.changes} changes, ${commitResult.summary.insertions} insertions and ${commitResult.summary.deletions} deletions.`); }); } } AmendLastCommand.description = 'Amends the last commit to repo'; exports.AmendLastCommand = AmendLastCommand;