Skip to content

Commit 95de824

Browse files
committed
Merge branch 'master' of https://github.com/theowenyoung/git-stats into new-version
2 parents 0daa270 + 6c3fbce commit 95de824

File tree

4 files changed

+766
-3
lines changed

4 files changed

+766
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Options:
9999
-d, --data <path> Sets a custom data store file.
100100
-l, --light Enables the light theme.
101101
-n, --disable-ansi Forces the tool not to use ANSI styles.
102+
-A, --author Filter author related contributions in the current
103+
repository.
102104
-a, --authors Shows a pie chart with the author related
103105
contributions in the current repository.
104106
-u, --until <date> Optional end date.

bin/git-stats

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ new Tilda(`${__dirname}/../package.json`, {
5656
opts: ["a", "authors"]
5757
, desc: "Shows a pie chart with the author related contributions in the current repository."
5858
}
59+
,{
60+
opts: ["A", "author"]
61+
, desc: "Filter author related contributions in the current repository."
62+
}
5963
, {
6064
opts: ["n", "disable-ansi"]
6165
, desc: "Forces the tool not to use ANSI styles."
@@ -96,7 +100,8 @@ new Tilda(`${__dirname}/../package.json`, {
96100
, lightOpt = action.options.light
97101
, dataPathOpt = action.options.data
98102
, globalActivityOpt = action.options.globalActivity
99-
, rawOpt = action.options.raw
103+
, rawOpt = action.options.raw,
104+
authorOpt = action.options.author
100105
;
101106

102107
let options = {};
@@ -163,6 +168,11 @@ new Tilda(`${__dirname}/../package.json`, {
163168
options.repo = process.cwd();
164169
}
165170

171+
// Add the author opt
172+
if(authorOpt.is_provided){
173+
options.author = authorOpt.value
174+
}
175+
166176
// Handle authors
167177
if (authorsOpt.is_provided) {
168178
options.no_ansi = noAnsiOpt.is_provided;

lib/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,8 @@ GitStats.prototype.globalActivity = function (options, callback) {
632632
repo: options
633633
};
634634
}
635+
console.log('options',options);
636+
635637

636638
options.repo = Abs(options.repo);
637639

@@ -643,8 +645,12 @@ GitStats.prototype.globalActivity = function (options, callback) {
643645
, today = null
644646
, cal = []
645647
;
648+
var logArgs = ["log","--since", options.start.format(DATE_FORMAT), "--until", options.end.format(DATE_FORMAT)]
649+
if(options.author){
650+
logArgs = logArgs.concat(["--author",options.author])
651+
}
646652

647-
GitLogParser(Spawn("git", ["log", "--since", options.start.format(DATE_FORMAT), "--until", options.end.format(DATE_FORMAT)], { cwd: options.repo }).stdout).on("commit", function(commit) {
653+
GitLogParser(Spawn("git",logArgs , { cwd: options.repo }).stdout).on("commit", function(commit) {
648654
if (!commit) { return; }
649655
today = Moment(commit.date).format(DATE_FORMAT);
650656
commits[today] = commits[today] || 0;

0 commit comments

Comments
 (0)