Skip to content

Commit

Permalink
Merge pull request #3 from jigsawye/add-branch-description
Browse files Browse the repository at this point in the history
Add branch description
  • Loading branch information
jigsawye authored Jun 19, 2018
2 parents b2ccf24 + 5386f1b commit 0c6809a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/git.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const git = require('simple-git/promise');

const getGitBranches = async () => {
const result = await git().branch();
return result;
};
const { white } = require('chalk');

exports.checkGit = async () => {
try {
Expand All @@ -15,8 +11,15 @@ exports.checkGit = async () => {
};

exports.getBranches = async () => {
const { current, all } = await getGitBranches();
return all.filter(branch => branch !== current);
const { branches } = await git().branch();

return Object.keys(branches)
.filter(name => !(branches[name].current || name.startsWith('remotes')))
.map(name => {
const { commit, label } = branches[name];
const description = white(`[${commit}] ${label}`);
return { name: `${name} ${description}`, value: name };
});
};

exports.deleteBranches = async branches => {
Expand Down

0 comments on commit 0c6809a

Please sign in to comment.