mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 13:22:11 +01:00
Use time range in git log and removed ascii progress bar
This commit is contained in:
parent
bb190ad095
commit
e93ece67f7
1 changed files with 14 additions and 35 deletions
49
lib/index.js
49
lib/index.js
|
@ -12,7 +12,6 @@ var Ul = require("ul")
|
||||||
, ChildProcess = require("child_process")
|
, ChildProcess = require("child_process")
|
||||||
, Exec = ChildProcess.exec
|
, Exec = ChildProcess.exec
|
||||||
, Spawn = ChildProcess.spawn
|
, Spawn = ChildProcess.spawn
|
||||||
, ProgressBar = require("progress")
|
|
||||||
;
|
;
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
@ -370,42 +369,22 @@ GitStats.globalActivity = function (options, callback) {
|
||||||
var commits = {}
|
var commits = {}
|
||||||
, today = null
|
, today = null
|
||||||
, cal = []
|
, cal = []
|
||||||
, isFinished = false
|
|
||||||
, timeout = null
|
|
||||||
, progress = null
|
|
||||||
, complete = 0
|
|
||||||
;
|
;
|
||||||
|
|
||||||
Exec("git rev-list HEAD --count", { cwd: options.repo }, function (err, commitCount) {
|
GitLogParser(Spawn("git", ["log", "--since", options.start.format(DATE_FORMAT), "--until", options.end.format(DATE_FORMAT)], { cwd: options.repo }).stdout).on("commit", function(commit) {
|
||||||
if (err) { return callback(err); }
|
today = Moment(commit.date).format(DATE_FORMAT);
|
||||||
commitCount = parseInt(commitCount);
|
commits[today] = commits[today] || 0;
|
||||||
setTimeout(function () {
|
++commits[today];
|
||||||
if (isFinished) { return; }
|
}).on("error", function (err) {
|
||||||
progress = new ProgressBar(":bar", { total: commitCount - complete });
|
callback(err);
|
||||||
}, 10);
|
}).on("finish", function () {
|
||||||
// TODO Take only the commits from the provided range (start - end)
|
Object.keys(commits).forEach(function (c) {
|
||||||
GitLogParser(Spawn("git", ["log"], { cwd: options.repo }).stdout).on("commit", function(commit) {
|
cal.push([c, commits[c]])
|
||||||
today = Moment(commit.date).format(DATE_FORMAT);
|
|
||||||
commits[today] = commits[today] || 0;
|
|
||||||
++commits[today];
|
|
||||||
++complete;
|
|
||||||
if (progress) {
|
|
||||||
progress.tick();
|
|
||||||
}
|
|
||||||
}).on("error", function (err) {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
callback(err);
|
|
||||||
}).on("finish", function () {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
isFinished = true;
|
|
||||||
Object.keys(commits).forEach(function (c) {
|
|
||||||
cal.push([c, commits[c]])
|
|
||||||
});
|
|
||||||
callback(null, CliGhCal(cal, {
|
|
||||||
theme: options.theme
|
|
||||||
, start: options.start
|
|
||||||
, end: options.end
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
callback(null, CliGhCal(cal, {
|
||||||
|
theme: options.theme
|
||||||
|
, start: options.start
|
||||||
|
, end: options.end
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue