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.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const AbstractStashCommand_1 = require("../abstracts/AbstractStashCommand");
const git_1 = require("../wrapper/git");
const OperationUtils_1 = require("../utils/OperationUtils");
class StashChangesCommand extends AbstractStashCommand_1.default {
getPrompts() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return [
{
message: 'The following changes will be stashed',
type: 'checkbox',
choices: this.choices,
name: 'filesToBeStashed',
when: this.choices.length > 0,
validate(choices) {
return choices.length > 0;
}
},
{
message: 'Stash message',
type: 'input',
name: 'stashMessage',
validate(message) {
return message !== '';
}
}
];
});
}
performStashOperation(answers) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let partial = true;
if (answers.filesToBeStashed.length === this.choices.length) {
partial = false;
}
OperationUtils_1.OperationUtils.addNewFilesToRepo(answers.filesToBeStashed);
const filePaths = [];
answers.filesToBeStashed.forEach(file => {
filePaths.push(file.path);
});
yield git_1.GitFacade.stash(answers.stashMessage, filePaths, partial);
});
}
run() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.runHelper();
});
}
}
StashChangesCommand.description = 'Stashes the changes in the workspace';
exports.StashChangesCommand = StashChangesCommand;