Git Churn
The purpose of this tool is to calculate change churn below the file-level. Git can already calculate churn with git log --numstat which will print how many lines of text were added and removed in each file touched by a commit. This tool prints the same information for each tag touched by a commit. A tag is any item in a source file such as a class, function, field, etc. We detect tags using Universal CTags. In effect, this tool is just some glue between ctags and git.
Install
gitchurn can be installed with pip.
pip install gitchurn
Git must also be installed. Universal CTags is also required. Please follow the link for instructions. You can test your install by running ctags --version.
Usage
Simply navigate to a git repository and run python -m gitchurn or just gitchurn. You will see something like:
9d0e3d1af0cb7e62c810ec23f97e12e86ab3cf6f 14 <tag_1>
9d0e3d1af0cb7e62c810ec23f97e12e86ab3cf6f 15 <tag_2>
a058e4559d0363ed956780e81f2e6f0d84d0ead3 2 <tag_3>
The output is always three columns delimated by tabs. The first column is the commit hash. The second column is the churn (added plus deleted lines). The last column is the tag. By default, tags are printed in a human readable format but this can be changed with --tag-format. See gitchurn --help for further options.
These churn calculations are fairly expensive and are not going to fluxuate, so it might be wise to immediately pipe the output to a file. You will also see significant performance gains by filtering down commits. See the next section for more details.
Example
For a more involved example, say we want the churn for the last 100 commits of some project. Let's use Apache DeltaSpike as an example.
git clone https://github.com/apache/deltaspike
cd deltaspike
gitchurn --git-log-args "master -n 100"
The arguments passed to --git-log-args will be fowarded to git-log. So master -n 100 means we want only the 100 most recent commits reachable from the master branch.
Now we can limit this even further. Say we are only interested in Java code which is not tests.
gitchurn --git-log-args "master -n 100 -- **/*.java :^**/src/test/**"
Everything after -- is interpreted as path information by git-log. So **/*.java is a glob telling git to only select Java files. Similarly, :^**/src/test/** tells git to exclude tests. (The :^ prefix causes git to invert the selection.)
Finally, if we want to ignore large commits (such as those caused by refactoring), we can set a maximum commit size.
gitchurn --git-log-args "master -n 100 -- **/*.java :^**/src/test/**" --max-changes 30
So any commits which have changed more than 30 non-test Java files will be excluded.
Metadata
Release files for gitchurn 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gitchurn-0.0.4.tar.gz | 12.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gitchurn-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.9 kB
Release files / gitchurn-0.0.4.tar.gz
| Download URL | gitchurn-0.0.4.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3121881f8f3a5533f82dd1ecede476a9c42e73168ed8ba44b4ae75e043503879
|
|
BLAKE2b-256 checksum How to use checksums |
9b194ee97e06c343966779b1c9a640979f882879f96c181aeb7109edea7061a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5
|
Release files / gitchurn-0.0.4-py3-none-any.whl
| Download URL | gitchurn-0.0.4-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab10d3825f0a98cf5dc08e4ecbd4dfc89615ea80a00215193394994adadc0e80
|
|
BLAKE2b-256 checksum How to use checksums |
3b0ffea4beb497926562c3a4df31a3c9fa543fdfd913962de480616376c4b8bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5
|