Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ return the result of `git rev-parse HEAD`; optional `filePath` parameter can be

return the current branch; optional `filePath` parameter can be used to run the command against a repo outside the current working directory

#### `git.count()` → <Number>
#### `git.count([branch])` → <Number>

return the count of commits across all branches; this method will fail if the `git` command is not found in `PATH`
returns the count of commits across all branches; optional `branch` parameter can be used to limit the count to a specific branch; this method will fail if the `git` command is not found in `PATH`

#### `git.date()` → <Date>

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ function date() {
return new Date(_command('git', ['log', '--no-color', '-n', '1', '--pretty=format:"%ad"']));
}

function count() {
return parseInt(_command('git', ['rev-list', '--all', '--count']), 10);
function count(branch) {
return parseInt(_command('git', ['rev-list', '--count', branch || '--all']), 10);
}

function log() {
Expand Down
4 changes: 4 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ result = git.count();
assert.notEqual(result, 0, 'count() returns a non-zero number');
assert.equal(Math.abs(result), result, 'count() returns a positive number');

result = git.count('HEAD');
assert.notEqual(result, 0, 'count() returns a non-zero number');
assert.equal(Math.abs(result), result, 'count() returns a positive number');

result = git.date();
assert.equal(result instanceof Date, true, 'date() returns a date');

Expand Down