git-stat-project
v0.5.2
Published
A tool for git projects statistics generation per every user.
Downloads
28
Readme
Git project stat
A tool for git projects statistics generation per every user.
What does the result look like?
I've used rship repo for this example.
pkondratenko:~/projects/experimental/git-stat-project (*)
> yarn start -- --folder ~/projects/tmp/rship --after 01.01.2017 --before 31.12.2017
yarn start v0.18.1
$ node ./script.js --folder /Users/pkondratenko/projects/tmp/rship --after 01.01.2017 --before 31.12.2017
Commits pushed report
User name Total value ratio Count
[email protected] |██████████████████████████████████████████████████ 16
[email protected] |█████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 3
[email protected] |██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2
[email protected] |███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1
[email protected] |███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1
Lines affected report (added plus removed)
User name Total value ratio Count
[email protected] |██████████████████████████████████████████████████ 691
[email protected] |█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 63
[email protected] |█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 20
[email protected] |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 4
[email protected] |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0
Lines diff report (added minus removed)
User name Total value ratio Count
[email protected] ░░░░░░░░░░░░░░░░░░░░░░░░░|░░░░░░░░░░░░░░░░░░░░░░░░░ 0
[email protected] ░░░░░░░░░░░░░░░░░░░░░░░░░|░░░░░░░░░░░░░░░░░░░░░░░░░ 0
[email protected] ░░░░░░░░░░░░░░░░░░░░░░░░░|░░░░░░░░░░░░░░░░░░░░░░░░░ 0
[email protected] ░░░░█████████████████████|░░░░░░░░░░░░░░░░░░░░░░░░░ -33
[email protected] █████████████████████████|░░░░░░░░░░░░░░░░░░░░░░░░░ -39
Done in 0.33s.Requirements
If you want to use this in your console, you need to use node.js >= 7.1.
Installation as a global package
1. Install via npm
npm install -g git-stat-project2. Use through console
git-stat-project --folder ~/projects/project --after 01.01.2017 --before 01.12.2017Installation as separate project
1. Clone the repo
git clone [email protected]:gustarus/git-stat-project.git && cd git-stat-project2. Use needed node.js version
nvm use3. Install dependencies
yarnOr via npm:
npm i4. Use through console
Clone and install this project and then type in console from this project dir:
yarn start -- --folder ~/projects/project --after 01.01.2017 --before 01.12.2017Or via npm:
npm start -- --folder ~/projects/project --after 01.01.2017 --before 01.12.2017How you can use this in your project?
This code u can find in script.js.
const stat = require('git-stat-project');
const {helpers, Log, GitProject, CommitsReport, LinesAffectedReport, LinesDiffReport} = stat;
const {getArgv} = helpers;
const {folder, before, after} = getArgv(process.argv);
const reports = [CommitsReport, LinesAffectedReport, LinesDiffReport];
const log = new Log();
const git = new GitProject({folder});
git.stat(after, before).then(collection => {
if (!Object.keys(collection).length) {
throw new Error('There is no history for this project. May be the folder is incorrect?');
}
return reports.map(Report => {
const report = new Report({collection});
const records = report.generate();
return report.render(records);
});
}).then(blocks => {
log.info('\n' + blocks.join('\n\n') + '\n');
}).catch(error => {
log.error(`\n${error.stack}\n`);
process.exit(1);
});Which kinds of reports do you have?
Each report can be required with the following syntax (where collection - git statistic results from GitProject instance):
const {GeneralReport} = require('git-stat-project');
const report = new Report({collection});
const records = report.generate();
return report.render(records);GeneralReport
General report - commits pushed and lines affected ratio
User name Percents value Commits Lines
[email protected] |██████████████████████████████████████████████████ 16 691
[email protected] |██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 3 63
[email protected] |███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2 20
[email protected] |█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1 4
[email protected] |█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1 0CommitsReport
Commits pushed report
User name Total value ratio Commits
[email protected] |██████████████████████████████████████████████████ 16
[email protected] |█████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 3
[email protected] |██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2
[email protected] |███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1
[email protected] |███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1LinesAddedReport
Lines added report
User name Total value ratio Added
[email protected] |██████████████████████████████████████████████████ 329
[email protected] |██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 12
[email protected] |██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 10
[email protected] |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2
[email protected] |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0LinesRemovedReport
Lines removed report
User name Total value ratio Removed
[email protected] |██████████████████████████████████████████████████ 362
[email protected] |███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 51
[email protected] |█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 10
[email protected] |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2
[email protected] |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0LinesDiffReport
Lines diff report (added minus removed)
User name Total value ratio Diff
[email protected] ░░░░░░░░░░░░░░░░░░░░░░░░░|░░░░░░░░░░░░░░░░░░░░░░░░░ 0
[email protected] ░░░░░░░░░░░░░░░░░░░░░░░░░|░░░░░░░░░░░░░░░░░░░░░░░░░ 0
[email protected] ░░░░░░░░░░░░░░░░░░░░░░░░░|░░░░░░░░░░░░░░░░░░░░░░░░░ 0
[email protected] ░░░░█████████████████████|░░░░░░░░░░░░░░░░░░░░░░░░░ -33
[email protected] █████████████████████████|░░░░░░░░░░░░░░░░░░░░░░░░░ -39LinesAffectedReport
Lines affected report (added plus removed)
User name Total value ratio Affected
[email protected] |██████████████████████████████████████████████████ 691
[email protected] |█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 63
[email protected] |█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 20
[email protected] |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 4
[email protected] |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0What does the module export?
// base components
module.exports.Base = require('./components/base/base');
module.exports.Log = require('./components/base/log');
module.exports.GitProject = require('./components/base/git-project');
module.exports.Report = require('./components/base/report');
module.exports.KeyReport = require('./components/base/key-report');
module.exports.Table = require('./components/base/table');
// key reports
module.exports.CommitsReport = require('./components/reports/key/commits');
module.exports.LinesDiffReport = require('./components/reports/key/lines-diff');
module.exports.LinesAddedReport = require('./components/reports/key/lines-added');
module.exports.LinesRemovedReport = require('./components/reports/key/lines-removed');
module.exports.LinesAffectedReport = require('./components/reports/key/lines-affected');
// more complicated reports
module.exports.GeneralReport = require('./components/reports/general');