Skip to content

Commit

Permalink
Merge branch 'release/0.2.5'
Browse files Browse the repository at this point in the history
* release/0.2.5:
  chore(release): 0.2.5
  fix(deps): resolve npm audit issues
  chore: update .gitigore file
  feat(cli): add support for --json option
  refactor binary: make use of lib to remove redundancies
  • Loading branch information
David Linse committed Apr 23, 2022
2 parents 4f85dcd + eca6309 commit 6fdacdc
Show file tree
Hide file tree
Showing 8 changed files with 1,417 additions and 4,389 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@

.idea/
.vscode/

.DS_Store

dist/
lib-cov/
npm-debug.log
node_modules/
reports/

yarn-error.log
94 changes: 22 additions & 72 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,98 +1,48 @@
<a name="0.2.4"></a>
### 0.2.4 (2022-02-10)
# Changelog

* update dependencies via `npm audit fix`
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

#### Bug Fixes
### [0.2.5](https://github.com/davidlinse/git-contributors.js/compare/v0.2.4...v0.2.5) (2022-04-23)

* Failing travis build ([609c279c](https://github.com/davidlinse/git-contributors.js/commit/609c279c8a3531827554ef9bb5ce7a494dea6001))

### Features

<a name="0.2.3"></a>
### 0.2.3 (2015-06-14)
* **cli:** add support for --json option ([478f3d7](https://github.com/davidlinse/git-contributors.js/commit/478f3d7c35454476e5097cb5bfb2c419761ec5dd))

* minor refactorings

### Bug Fixes

<a name="0.2.2"></a>
### 0.2.2 (2015-06-08)
* **deps:** resolve npm audit issues ([ea1b8e2](https://github.com/davidlinse/git-contributors.js/commit/ea1b8e2dc678d493ddf1d9d11aa2eadacd7e769e))

* maintenance release including minor fixes and updated dependencies
### [0.1.10](https://github.com/davidlinse/git-contributors.js/compare/v0.1.9...v0.1.10) (2014-06-09)


<a name="0.2.0"></a>
## 0.2.0 (2014-08-22)
### Bug Fixes

* **lib:** calculation of commits w/ different mail ([7ef93c0](https://github.com/davidlinse/git-contributors.js/commit/7ef93c01c86a873b999b86583da37147c1dcc321)), closes [#8](https://github.com/davidlinse/git-contributors.js/issues/8)

#### Features
### [0.1.9](https://github.com/davidlinse/git-contributors.js/compare/v0.1.8...v0.1.9) (2014-06-07)

* **cli-options:** suppress email via --no-email option ([1e32ff42](https://github.com/davidlinse/git-contributors.js/commit/1e32ff42cff94022a75acc4286e6d84db8d538a4))
* using _promises_ now

<a name="0.1.11"></a>
### 0.1.11 (2014-08-13)
### Features

* minor refactorings
* give at least 0.1 percent contribution ([8600dc0](https://github.com/davidlinse/git-contributors.js/commit/8600dc084d87ed51e5e7328e5278852d5984856c)), closes [#7](https://github.com/davidlinse/git-contributors.js/issues/7)
* print usage example in case of invalid path ([064b52d](https://github.com/davidlinse/git-contributors.js/commit/064b52df4740f9b3537449c850b663cf2178c34f))

### [0.1.5](https://github.com/davidlinse/git-contributors.js/compare/v0.1.4...v0.1.5) (2014-04-21)

<a name="0.1.10"></a>
### 0.1.10 (2014-06-09)

### Bug Fixes

#### Bug Fixes
* **lib:** calculate commits based on email ([14d23f8](https://github.com/davidlinse/git-contributors.js/commit/14d23f8efba0502214e8150a1bf1f6789b1022e3)), closes [#2](https://github.com/davidlinse/git-contributors.js/issues/2)

* **lib:** calculation of commits w/ different mail ([7ef93c01](https://github.com/davidlinse/git-contributors.js/commit/7ef93c01c86a873b999b86583da37147c1dcc321), closes [#8](https://github.com/davidlinse/git-contributors.js/issues/8))
### [0.1.3](https://github.com/davidlinse/git-contributors.js/compare/v0.1.2...v0.1.3) (2014-04-18)


<a name="0.1.9"></a>
### 0.1.9 (2014-06-05)
### Features

* **cli:** parse cli opts with "commander" ([ca382bd](https://github.com/davidlinse/git-contributors.js/commit/ca382bd5533e6eabb0ce1b5f11bb533c1b6d2840))

#### Features
### [0.1.2](https://github.com/davidlinse/git-contributors.js/compare/v0.1.1...v0.1.2) (2014-03-13)

* give at least 0.1 percent contribution ([8600dc08](https://github.com/davidlinse/git-contributors.js/commit/8600dc084d87ed51e5e7328e5278852d5984856c), closes [#7](https://github.com/davidlinse/git-contributors.js/issues/7))


<a name="0.1.6"></a>
### 0.1.6 (2014-05-19)


#### Features

* print usage example in case of invalid path ([064b52df](https://github.com/davidlinse/git-contributors.js/commit/064b52df4740f9b3537449c850b663cf2178c34f))


<a name="0.1.5"></a>
### 0.1.5 (2014-04-21)


#### Bug Fixes

* **lib:** calculate commits based on email ([14d23f8e](https://github.com/davidlinse/git-contributors.js/commit/14d23f8efba0502214e8150a1bf1f6789b1022e3), closes [#2](https://github.com/davidlinse/git-contributors.js/issues/2))


<a name="0.1.4"></a>

### 0.1.4 (2014-04021)
* **change:** a _`/path/to/repository-dir/` is _mandatory_ now
* **test:** add fixture based testing

<a name="0.1.4"></a>

### 0.1.3 (2014-04-19)
* **lib:** minor refactorings


<a name="0.1.2"></a>

### 0.1.2 (2014-03-14)

#### Features

* **cli:** parse cli opts with "commander" ([ca382bd5](git://github.com/davidlinse/git-contributors.js/commit/ca382bd5533e6eabb0ce1b5f11bb533c1b6d2840))


<a name="0.1.1"></a>

### 0.1.1 ()
* status badges
### [0.1.1](https://github.com/davidlinse/git-contributors.js/compare/v0.1.0...v0.1.1) (2014-02-27)
165 changes: 14 additions & 151 deletions bin/git-contributors
Original file line number Diff line number Diff line change
Expand Up @@ -12,166 +12,29 @@

var fs = require('fs'),
path = require('path'),
git = require('../lib/gitlog'),
_ = require('lodash');
var Q = require('q');
_ = require('lodash'),
cli = require('../lib/_cli');

var verifyRepositoryExists = function() {
'use strict';

var deferred = Q.defer();
var repo = path.join(program.cwd, '.git');
var ok = fs.existsSync(program.cwd) && fs.existsSync(repo);

if (ok) { deferred.resolve(program); }
else {
deferred.reject(
new Error('Could not find .git repository at "'+ program.cwd +'"')
);
}

return deferred.promise;
};

var processLog = function(stdout) {
'use strict';

var deferred = Q.defer();

var list,
entries = _.compact(stdout.split('\n')),
total = _.size(entries);

list = _.map(_.uniq(entries), function(committer) {

var parts = committer.split(' '),
email = _.last(parts),
author = _.without(parts, email).join(' '),
commits = _.size(_.filter(entries, function(e) {
return e.indexOf(author) > -1 && e.indexOf(email) > -1;
})),
percentage = (commits / total * 100);

return {
commits: commits,
name: author,
email: email,
percent: parseFloat(Math.max(0.1, percentage).toFixed(1), 10)
};
});

list = _.sortBy(list, function(committer) {
return -committer.commits;
});

deferred.resolve(list);

return deferred.promise;
};

var format = function(data) {
'use strict';

var deferred = Q.defer();

if (program.markdown === true) {
data = require('../lib/markdown-reporter').format(data, program);
}

if (program.json === true) {
data = JSON.stringify(data);
}
deferred.resolve(data);
var pkg = path.resolve(__dirname + '/../package.json');

return deferred.promise;
};
var version = JSON.parse(fs.readFileSync(pkg, 'utf-8')).version;

var filter = function(data) {
'use strict';

var deferred = Q.defer();

var stripEmail = function(el) {
return _.omit(el, 'email');
};

if (program.email === false) {
data = _.map(data, stripEmail);
}

deferred.resolve(data);
var program = {};

return deferred.promise;
};
program = _.merge(cli.parse(process.argv, version), program);
program.cwd = _.first(program.args);

//--

var program = {
timeout: 5000,
cwd: '.',
maxBuffer: 25000 * 1024
};
var GitContributors = require('../lib/git-contributors').GitContributors;


var GitContributors = function GitContributors () {};

GitContributors.prototype.list = function(opts, cb) {
GitContributors.list(program, function(err, result) {
'use strict';

program.markdown = null;
program.json = null;

if (_.isString(opts)) {
program.cwd = opts;
}
else {
program = _.merge(program, opts);
}

Q()
.then(verifyRepositoryExists)
.then(git.log)
.then(processLog)
.then(filter)
.then(format)
.done(function(result) {
cb(null, result);
}, function(err) {
cb(err, null);
});
};

module.exports.GitContributors = new GitContributors();


// binary

if (!module.parent) {

var fs = require('fs');
var pkg = path.resolve(__dirname + '/../package.json');

var version = JSON.parse(fs.readFileSync(pkg, 'utf-8')).version;

program = _.merge(require('../lib/_cli').parse(process.argv, version), program);
program.cwd = _.first(program.args);

var success = function(result) {
'use strict';
console.log(result);
};

Q()
.then(verifyRepositoryExists)
.then(git.log)
.then(processLog)
.then(filter)
.then(format)
.then(success)
.catch(function(err){
'use strict';
if (err) {
console.log(err.message);
process.exit(1);
});
}
}

console.log(result);
process.exit(0);
});
8 changes: 7 additions & 1 deletion lib/git-contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@ var format = function(data) {
'use strict';

var deferred = Q.defer();
var stringify = program.markdown === true && program.json === true;

if (program.markdown === true) {
if (program.markdown) {
data = require('../lib/markdown-reporter').format(data, program);
}

if (stringify) {
data = _.trim(data, '\n').split('\n');
}

if (program.json === true) {
data = JSON.stringify(data);
}

deferred.resolve(data);

return deferred.promise;
Expand Down
6 changes: 1 addition & 5 deletions lib/markdown-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
/* jshint indent:2 */

var _ = require('lodash');
var Q = require('q');

module.exports.format = function(data, opts) {

Expand All @@ -20,7 +19,6 @@ module.exports.format = function(data, opts) {
opts = opts || {};

var report = '';
var deferred = Q.defer();

report += (opts.header || '');

Expand All @@ -34,7 +32,5 @@ module.exports.format = function(data, opts) {
'\n';
});

deferred.resolve(report);

return deferred.promise;
return report;
};
Loading

0 comments on commit 6fdacdc

Please sign in to comment.