Skip to content

Commit

Permalink
feat(commit): check if a git tree is clean
Browse files Browse the repository at this point in the history
  • Loading branch information
vivaxy committed Nov 27, 2016
1 parent 2ef6029 commit 707750d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import isAGitRepository from '../lib/isAGitRepository';
import isGitStatusClean from '../lib/isGitStatusClean';
import * as console from '../lib/console';
import acp from '../lib/acp';
import prompt from '../lib/prompt';
Expand All @@ -13,6 +14,10 @@ export default async() => {
console.error(`not a git repository`);
process.exit(1);
}
if (isGitStatusClean()) {
console.error(`nothing to commit, working tree clean`);
process.exit(1);
}
const commitMessage = await prompt();
acp(commitMessage);
};
10 changes: 10 additions & 0 deletions lib/isGitStatusClean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @since 2016-11-27 13:49
* @author vivaxy
*/

import getInfoFromShell from './getInfoFromShell';

export default () => {
return getInfoFromShell(`git status -s`) === ``;
};

0 comments on commit 707750d

Please sign in to comment.