ogit
Version:
A lazy developer's Git CLI made simple. Makes using git on cloud IDEs (i.e. C9) a walk in the park.
60 lines (59 loc) • 2.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
require("reflect-metadata");
const terminalLink = require('terminal-link');
const chalk = require('chalk');
const columnify = require('columnify');
const git_1 = require("../wrapper/git");
const command_1 = require("@oclif/command");
class DisplayChangesCommand extends command_1.Command {
run() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const status = yield git_1.GitFacade.status();
const remoteBranch = status.trackingBranch
? yield git_1.GitFacade.originUrl()
: null;
let message = `Your are on branch ${chalk.blue(status.currentBranch)}`;
if (remoteBranch) {
message += ' tracking ';
message += chalk.yellow(terminalLink(status.trackingBranch, remoteBranch));
}
console.log(message);
const dataTable = [];
for (let file of status.created) {
dataTable.push({
change: 'New',
path: file.path
});
}
for (let file of status.added) {
dataTable.push({
change: 'Added',
path: file.path
});
}
for (let file of status.modified) {
dataTable.push({
change: 'Modified',
path: file.path
});
}
for (let file of status.deleted) {
dataTable.push({
change: 'Deleted',
path: file.path
});
}
if (dataTable.length > 0) {
console.log(columnify(dataTable, {}));
}
else {
console.log(chalk.yellow('You do not have any uncommitted changes'));
}
});
}
}
DisplayChangesCommand.description = 'Display all the uncommitted changes';
DisplayChangesCommand.aliases = ['status'];
exports.default = DisplayChangesCommand;