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.

62 lines (61 loc) 2.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const git_1 = require("../wrapper/git"); const AbstractCommitCommand_1 = require("../abstracts/AbstractCommitCommand"); class CommitChangesCommand 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* () { return [ { message: 'The following changes needs to be committed', type: 'checkbox', choices: this.choices, name: 'fileToBeCommitted', when: this.choices.length > 0, validate(choices) { return choices.length > 0; } }, { message: 'Commit message', type: 'input', name: 'commitMessage', validate(message) { return message !== ''; } }, { message: 'Skip verification', type: 'confirm', name: 'skipValidation', default: false } ]; }); } runCommit(message, fileNames, skipValidation) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const commitResult = yield git_1.GitFacade.commit(message, fileNames, skipValidation); const { flags } = this.parse(CommitChangesCommand); if (!flags.noSummary) { console.log(`Commit ${commitResult.commit} for branch ${commitResult.branch} was successful with ${commitResult.summary.changes} changes, ${commitResult.summary.insertions} insertions and ${commitResult.summary.deletions} deletions.`); } }); } } CommitChangesCommand.description = 'Commit all the uncommitted changes to repo'; CommitChangesCommand.flags = { noSummary: command_1.flags.boolean({ default: false, description: 'Do not display commit summary' }) }; exports.CommitChangesCommand = CommitChangesCommand;