diff options
author | Kimmo Brunfeldt <kimmobrunfeldt@gmail.com> | 2014-07-09 18:26:51 +0300 |
---|---|---|
committer | Kimmo Brunfeldt <kimmobrunfeldt@gmail.com> | 2014-07-09 18:26:51 +0300 |
commit | 23ad7f895f01412b52cf930026348f3ed8610ffe (patch) | |
tree | 356690fbcf31e5eb7c0c92ba4febe6c95d83df29 | |
parent | d48e9a07247ff112723ede1aec055658157721a8 (diff) | |
download | git-hours-23ad7f895f01412b52cf930026348f3ed8610ffe.zip git-hours-23ad7f895f01412b52cf930026348f3ed8610ffe.tar.gz git-hours-23ad7f895f01412b52cf930026348f3ed8610ffe.tar.bz2 |
Fix bug with getting branches
-rwxr-xr-x | index.js | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -74,10 +74,8 @@ function commits(gitPath) { // Get all commits for all branches getBranchNames(gitPath).map(function(branchName) { - console.log(branchName); return getBranch(repo, branchName); }).map(function(branch) { - console.log(branch); return getBranchCommits(branch); }).reduce(function(allCommits, branchCommits) { _.each(branchCommits, function(commit) { @@ -98,14 +96,18 @@ function commits(gitPath) { function getBranchNames(gitPath) { var cmd = "git branch --no-color | awk -F ' +' '! /\(no branch\)/ {print $2}'"; - return exec(cmd, {cwd: gitPath}).then(function(stdout, stderr) { - if (stderr) { - throw new Error(stderr); - } + return new Promise(function(resolve, reject) { + exec(cmd, {cwd: gitPath}, function(err, stdout, stderr) { + if (err) { + reject(err); + } - return stdout - .filter(function(e) { return e; }) // Remove empty - .map(function(str) { return str.trim(); }); // Trim whitespace + resolve(stdout + .split('\n') + .filter(function(e) { return e; }) // Remove empty + .map(function(str) { return str.trim(); }) // Trim whitespace + ) + }); }); } |