all files / src/commitizen/ staging.js

100% Statements 9/9
100% Branches 5/5
100% Functions 2/2
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                        
import git from 'gulp-git';
import {isString} from '../common/util';
 
export {isClean};
 
/**
 * Asynchrounously determines if the staging area is clean
 */
function isClean(repoPath, done) {
  git.exec({cwd:repoPath, args: '--no-pager diff --cached --name-only', quiet: true}, function (err, stdout) {
    let stagingIsClean;
    if(stdout && isString(stdout) && stdout.trim().length>0)
    {
      stagingIsClean = false;
    } else {
      stagingIsClean = true;
    }
    done(stagingIsClean);
  });
}