ogit
Version:
A lazy developer's Git CLI made simple. Makes using git on cloud IDEs (i.e. C9) a walk in the park.
57 lines (56 loc) • 2.22 kB
JavaScript
;
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 ResetHeadCommand extends command_1.Command {
run() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const choices = [];
const branchesList = yield git_1.GitFacade.listBranches();
branchesList.forEach(branch => {
choices.push({
name: `${branch.name} (branch)`,
value: branch.name
});
});
const tagResult = yield git_1.GitFacade.tags();
tagResult.all.forEach(tag => choices.push({ name: `${tag} (tag)`, value: tag }));
const answers = yield inquirer.prompt([
{
message: 'Select the branch or tag name to reset HEAD to',
type: 'list',
choices,
name: 'selectedPosition',
validate(choices) {
return choices.length > 0;
}
},
{
message: 'What strategy should you use?',
type: 'list',
choices: [
{
name: 'Simply move the branch HEAD',
value: '--soft'
},
{
name: 'Make the Index look like HEAD ',
value: '--hard'
},
{
name: 'Make the Working Directory look like the Index',
value: '--mixed'
}
],
name: 'strategy'
}
]);
// console.log(answers);
yield git_1.GitFacade.reset(answers.selectedPosition, answers.strategy);
});
}
}
ResetHeadCommand.description = 'Resets the current HEAD to a branch or tag';
exports.default = ResetHeadCommand;