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.

54 lines (53 loc) 2.1 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 inquirer = require("inquirer"); class PushCommits extends command_1.Command { run() { return tslib_1.__awaiter(this, void 0, void 0, function* () { yield git_1.GitFacade.syncRemoteBranches(); const status = yield git_1.GitFacade.status(); const branchesList = yield git_1.GitFacade.listBranches(); const branchChoices = [ { name: status.currentBranch, value: status.currentBranch }, { name: `${status.trackingBranch} (upstream)`, value: `HEAD:${status.currentBranch}` } ]; // console.log(branchChoices); branchesList.forEach(branch => { if (!branch.isLocal && branch.name !== status.currentBranch && branch.name !== status.trackingBranch) { branchChoices.push({ name: branch.name, value: branch.name }); } }); if (status.currentBranch !== status.trackingBranch) { const answers = yield inquirer.prompt([ { message: 'Select the remote branch to push commits to', type: 'checkbox', choices: branchChoices, default: status.currentBranch, name: 'branchNames', validate(choices) { return choices.length > 0; } } ]); yield git_1.GitFacade.push(answers.branchNames); } }); } } PushCommits.description = 'Pushes local commits to the remote repo'; exports.default = PushCommits;