summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKimmo Brunfeldt <kimmobrunfeldt@gmail.com>2014-07-09 18:26:51 +0300
committerKimmo Brunfeldt <kimmobrunfeldt@gmail.com>2014-07-09 18:26:51 +0300
commit23ad7f895f01412b52cf930026348f3ed8610ffe (patch)
tree356690fbcf31e5eb7c0c92ba4febe6c95d83df29
parentd48e9a07247ff112723ede1aec055658157721a8 (diff)
downloadgit-hours-23ad7f895f01412b52cf930026348f3ed8610ffe.zip
git-hours-23ad7f895f01412b52cf930026348f3ed8610ffe.tar.gz
git-hours-23ad7f895f01412b52cf930026348f3ed8610ffe.tar.bz2
Fix bug with getting branches
-rwxr-xr-xindex.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/index.js b/index.js
index d888c68..473fae5 100755
--- a/index.js
+++ b/index.js
@@ -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
+ )
+ });
});
}