Pretty-print git repository collaborators sorted by contributions.
https://git-fame.cdcl.ml/gh/{owner}/{repo}
git-fame --cost hour,month --loc insProcessing: 100%|██████████████████████████| 1/1 [00:00<00:00, 2.16repo/s]
Total commits: 1775
Total atimes: 2770
Total files: 461
Total hours: 449.7
Total loc: 41659
Total months: 151.0
| Author | hrs | mths | loc | coms | fils | distribution |
|:---------------------|------:|-------:|------:|-------:|-------:|:----------------|
| Casper da Costa-Luis | 228 | 108 | 28572 | 1314 | 172 | 68.6/74.0/37.3 |
| Stephen Larroque | 28 | 18 | 5243 | 203 | 25 | 12.6/11.4/ 5.4 |
| pgajdos | 2 | 9 | 2606 | 2 | 18 | 6.3/ 0.1/ 3.9 |
| Martin Zugnoni | 2 | 5 | 1656 | 3 | 3 | 4.0/ 0.2/ 0.7 |
| Kyle Altendorf | 7 | 2 | 541 | 31 | 7 | 1.3/ 1.7/ 1.5 |
| Hadrien Mary | 5 | 1 | 469 | 31 | 17 | 1.1/ 1.7/ 3.7 |
| Richard Sheridan | 2 | 1 | 437 | 23 | 3 | 1.0/ 1.3/ 0.7 |
| Guangshuo Chen | 3 | 1 | 321 | 18 | 7 | 0.8/ 1.0/ 1.5 |
| Noam Yorav-Raphael | 4 | 1 | 229 | 11 | 6 | 0.5/ 0.6/ 1.3 |
| github-actions[bot] | 2 | 1 | 186 | 1 | 51 | 0.4/ 0.1/11.1 |
...The distribution column is a percentage breakdown of loc/coms/fils.
(e.g. in the table above, Casper has written surviving code in
172/461 = 37.3% of all files).
Table of contents
pip install git-famePull and install:
pip install "git+https://github.com/casperdcl/git-fame.git@main#egg=git-fame"conda install -c conda-forge git-famesnap install git-famedocker run --rm casperdcl/git-fame --help
docker run --rm -v "/local/path/to/repository:/repo" -u "$(id -u)" casperdcl/git-fameOn Windows, run:
git config --global alias.fame "!python -m gitfame"This is probably not necessary on UNIX systems.
If git fame doesn't work after restarting the terminal on Linux & Mac OS, try (with single quotes):
git config --global alias.fame '!python -m gitfame'This doesn't currently work with the alias (git fame), but does work with git-fame.
Completion scripts are generated by git-fame --print-completion <shell>. For example, in bash:
$ # Ensure completion works for `git` itself
$ sudo apt-get install bash-completion
$ # Install `git-fame` completions
$ git-fame --print-completion bash |
sudo tee /etc/bash_completion.d/git-fame_completion.bashSee shtab for more information on where to place the completion script for your shell.
The list of all changes is available on the Releases page:
git-fame # Console script (with tab completion support)
git-fame -h # Print help
python -m gitfame # Alternative execution as python module
git fame # Alternative git alias (see above)For example, to print statistics regarding all source files in a C++/CUDA
repository (*.c/h/t(pp), *.cu(h)), carefully handling whitespace and line
copies:
git-fame --incl '\.[cht][puh]{0,2}$' -twMCIt is also possible to run from within a python shell or script.
>>> import gitfame
>>> gitfame.main(['--sort=commits', '-wt', '/path/to/my/repo'])Finally, there is a live server for public GitHub repositories at git-fame.cdcl.ml/gh/{owner}/{repo}.
perks: the
rendered by git-fame.cdcl.ml watermark is removed & some options are unlocked (non-default branch, auth, show, ttl).
Usage:
git-fame [--help | options] [<gitdir>...]
Arguments:
<gitdir> Git directory [default: ./].
May be specified multiple times to aggregate across
multiple repositories.
Options:
-h, --help Print this help and exit.
-v, --version Print module version and exit.
--branch=<b> Branch or tag [default: HEAD] up to which to check.
--sort=<key> [default: loc]|commits|files|hours|months.
--min=<val> Minimum value (of `--sort` key) to show [default: 0:int].
--loc=<type> surv(iving)|ins(ertions)|del(etions)
What `loc` represents. Use 'ins,del' to count both.
defaults to 'surviving' unless `--cost` is specified.
--excl=<f> Excluded files (default: None).
In no-regex mode, may be a comma-separated list.
Escape (\,) for a literal comma (may require \\, in shell).
--incl=<f> Included files [default: .*]. See `--excl` for format.
--since=<date> Date from which to check. Can be absolute (eg: 1970-01-31)
or relative to now (eg: 3.weeks).
--until=<date> Date to which to check. See `--since` for format.
--cost=<method> Include time cost in person-months (COCOMO) or
person-hours (based on author times).
Methods: month(s)|cocomo|hour(s).
May be multiple comma-separated values.
Alters `--loc` default to imply 'ins' (COCOMO) or
'ins,del' (hours).
-R, --recurse Recursively find repositories & submodules within <gitdir>.
-n, --no-regex Treat `--incl`, `--excl` & `--ignore-author` as
comma-separated exact matches rather than regular
expressions [default: False].
NB: if regex is enabled ',' is equivalent to '|'.
-s, --silent-progress Suppress `tqdm` [default: False].
-j=<n>, --jobs=<n> Number of concurrent `git blame` threads per <gitfir>
[default: 0:int]: automatic.
--warn-binary Don't silently skip files which appear to be binary data
[default: False].
--auth=<strat> Credit commit trailers (`Co-authored-by`, `Assisted-by`):
[default: git]|first|share, i.e.: only use 'git' author,
only use 'first' trailer, or 'share' equally with git &
all trailers.
--show=<info> Author information to show [default: name]|email.
Use 'name,email' to show both.
-e, --show-email Shortcut for `--show=email`.
--enum Show row numbers [default: False].
-t, --bytype Show stats per file extension [default: False].
-w, --ignore-whitespace Ignore whitespace when comparing the parent's
version and the child's to find where the lines
came from [default: False].
-M Detect intra-file line moves and copies [default: False].
-C Detect inter-file line moves and copies [default: False].
--ignore-rev=<rev> Ignore changes made by the given revision
(requires `--loc=surviving`).
May be a comma-separated list.
--ignore-revs-file=<f> Ignore revisions listed in the given file
(requires `--loc=surviving`).
--ignore-author=<auth> Ignore revisions from this author regex
(requires `--loc=surviving`).
In no-regex mode, may be a comma-separated list.
Escape (\,) for a literal comma (may require \\, in shell).
--format=<format> Table format
fame|svg|[default: md]|yaml|json|csv|tsv.
Any `tabulate.tabulate_formats` is also accepted.
Most formats can also be prefixex by `svg-`, e.g. `svg-fame`.
--log=<lvl> FATAL|CRITICAL|ERROR|WARN(ING)|[default: INFO]|DEBUG|NOTSET.
If multiple user names and/or emails correspond to the same user, aggregate
git-fame statistics and maintain a git repository properly by adding a
.mailmap file.
- Options such as
-w,-M, and-Ccan increase accuracy, but take longer to compute. - Commits made by refactoring bots can be ignored using e.g.
--ignore-author='pre-commit-ci[bot]' --no-regex. Survivinglocare reassigned to the previous committer, but commit counts are unaffected.- For large numbers of commits, generate a file using
git log --format=%H --author=... > .git-blame-ignore-revsand pass it to--ignore-revs-fileinstead.
- For large numbers of commits, generate a file using
--sort=hoursand--sort=monthsrequire an appropriate--cost:--cost=months(--cost=COCOMO) approximates person-months and should be used with--loc=ins.--cost=hours(--cost=commits) approximates person-hours.
- Extra care should be taken when using
insand/ordelfor--locsince all historical files (including those no longer surviving) are counted. In such cases,--exclmay need to be significantly extended. On the plus side, it is faster to computeinsanddelcompared tosurv.
An SVG image for inclusion in README files and websites:
git-fame -wMC --format svg --min 1 > docs/authors.svgWhich can also be dynamically created for public GitHub repositories:
Generating CODEOWNERS:
# bash syntax function for current directory git repository
owners(){
for f in $(git ls-files); do
# filename
echo -n "$f "
# author emails if loc distribution >= 30%
git-fame -esnwMC --incl "$f" | tr '/' '|' \
| awk -F '|' '(NR>6 && $6>=30) {print $2}' \
| xargs echo
done
}
# print to screen and file
owners | tee .github/CODEOWNERS
# same but with `tqdm` progress for large repos
owners \
| tqdm --total $(git ls-files | wc -l) \
--unit file --desc "Generating CODEOWNERS" \
> .github/CODEOWNERSGenerating .zenodo.json:
git-fame -wMC --format json \
| jq -c '{creators: [.data[] | {name: .[0]}]}' \
| sed -r -e 's/(\{"name")/\n \1/g' -e 's/:/: /g' \
> .zenodo.jsonAll source code is hosted on GitHub. Contributions are welcome.
perks: the
rendered by git-fame.cdcl.ml watermark is removed & some options are unlocked (non-default branch, auth, show, ttl).