Skip to content

Commit

Permalink
#15: Using short SHA's and showing commit messages
Browse files Browse the repository at this point in the history
  • Loading branch information
RamonGebben committed Apr 23, 2018
1 parent 1563df5 commit efc60ef
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/commands/review/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ const { hasGit } = require('../../utils/hasGit');

const readDirAsync = promisify(readdir);

const getShas = () => new Promise((resolve) => {
const gitLog = exec('git log --format=format:%H');
const getCommits = () => new Promise((resolve) => {
const gitLog = exec('git log --format=format:[%h]\\ %s -20');
gitLog.stdout.on('data', (data) => {
resolve(data.split('\n').filter(x => x !== ''));
const commits = data.split('\n')
.filter(x => x !== '')
.map(x => x.substr(0, 40).concat('...'));

return resolve(commits);
});
});

Expand All @@ -20,8 +24,8 @@ const review = async({ userId }) => {
const files = await readDirAsync(currentWorkingDir);
const itHasGit = hasGit(files);
if (itHasGit) {
const shas = await getShas();
const choices = ['HEAD^', ...shas];
const commits = await getCommits();
const choices = ['HEAD^', ...commits];
const { sha = 'HEAD^' } = inquirer.prompt([{
name: 'sha',
message: 'From which commit do you want to review?',
Expand Down

0 comments on commit efc60ef

Please sign in to comment.