git-metrics
v2.2.2
Published
tools to calculate some metrics out of git repos
Downloads
305
Readme
git-metrics
git-metrics is set of apps used to work with git repos and calculate different measures on git repos.
run git-metrics apps
The apps can be launched with the command
npx git-metrics <app-name> <params>
or, if we have cloned git-metrics repo, from the git-metrics repo folder launching the command
node ./dist/lib/command.js <app-name> <params>
Executing npx git-metrics
prints on the console the list of available apps.
Executing npx git-metrics <app-name> -h
prints on the console the help for the specific app.
apps available
- code-turnover: calculates the code-turnover on the repos contained in a folder and save it to csv files - code-turnover is a measure of the effort spent to develop and maintain a codebase in a certain time window
- cloc-diff-between-dates: calculates the differences in the lines of code/comments/blanks between two dates in a set of repos contained in a folder
- read-repos-commits: reads all the commit records of a set of repos and save them on csv files - the result can be used to have an high level idea of how intense is the work on a certain codebase
- cloc-byfile-multi-repos: calculates the lines of code/comments/blanks on all the files in all the repos contained in a certain folder using the cloc command which, by default, works on a single repo
- fetch-repos: fetches the git repos contained in a folder and its subfolders
- pull-repos: pulls the git repos contained in a folder and its subfolders
apps deprecated
- cloc-monthly-diff-repos: calculates statistics about the changes that occurred on a codebase on a monthly basis, i.e. calculating the differences in the codebase between the last commit of a month and the last commit of the previous month - use code-turnover instead to have the real picture of the changes in a period of time
- reports: there are different reports that can be run on repos to gather statistics about, for instance, the files that have changed most in a certain period of time, the authors that have contributed more and so on - code-turnover instead and then build the desired pivots using the data generated
libraries
The apps use git and cloc commands to calculate their statistics.
Such commands are wrapped in functions provided by different libraries
- cloc-functions: wraps the cloc to provide different output, e.g. a dictionary of the files in a repo with the information about their lines of code or the differences, in terms lines of code/comment/blank added/deleted/renamed in a certain period of time
- git-functions: wraps different git commands, such as git log or git diff to provide different output, e.g. the list of all commits in a certain period of time or the differences between the files comparing two different commits
- git-cloc-functions: combines git and cloc commands to provide a more comprehensive set of information about the changes that have occurred in a repo in certain period of time
use of rxJs
git-metrics uses extensively the rxJs library.
The reason is that the git and cloc commands are often executed asynchronously using the node child-process functions in their 'callback based' form (i.e. exec and spawn).
The child-process 'callback based' functions are turned into rsJs Observables using functions provided in execute-command.
Converting 'callback based' functions into Observable streams allows to conveniently manipulate such streams via rxJs operators.