Skip to main content

Pretty-print `git` repository collaborators sorted by contributions

Project description

Pretty-print git repository collaborators sorted by contributions.

PyPI-Versions PyPI-Status Docker Snapcraft

Build-Status Coverage-Status Branch-Coverage-Status Codacy-Grade Libraries-Rank PyPI-Downloads

DOI-URI LICENCE OpenHub-Status Gift-Casper

~$ git fame --cost hour,month
Blame: 100%|██████████| 74/74 [00:00<00:00, 96.51file/s]
Total commits: 1173
Total ctimes: 1055
Total files: 180
Total hours: 255.1
Total loc: 2716
Total months: 8.7
| Author                     |   hrs |   mths |   loc |   coms |   fils |  distribution   |
|:---------------------------|------:|-------:|------:|-------:|-------:|:----------------|
| Casper da Costa-Luis       |   100 |      7 |  2171 |    770 |     63 | 79.9/65.6/35.0  |
| Stephen Larroque           |    16 |      1 |   243 |    202 |     19 | 8.9/17.2/10.6   |
| Kyle Altendorf             |     6 |      0 |    41 |     31 |      3 | 1.5/ 2.6/ 1.7   |
| Guangshuo Chen             |     2 |      0 |    35 |     18 |      6 | 1.3/ 1.5/ 3.3   |
| Matthew Stevens            |     2 |      0 |    32 |      3 |      2 | 1.2/ 0.3/ 1.1   |
| Noam Yorav-Raphael         |     3 |      0 |    23 |     11 |      4 | 0.8/ 0.9/ 2.2   |
| Daniel Panteleit           |     2 |      0 |    16 |      2 |      2 | 0.6/ 0.2/ 1.1   |
| Mikhail Korobov            |     2 |      0 |    15 |     11 |      6 | 0.6/ 0.9/ 3.3   |
| Hadrien Mary               |     3 |      0 |    15 |     31 |     10 | 0.6/ 2.6/ 5.6   |
| Johannes Hansen            |     2 |      0 |    14 |      1 |      2 | 0.5/ 0.1/ 1.1   |

The distribution column is a percentage breakdown of loc/coms/fils. (e.g. in the table above, Casper has written surviving code in 63/180 = 35.0% of all files).


Installation

Latest PyPI stable release

PyPI-Status PyPI-Downloads Libraries-Dependents

pip install git-fame

Latest development release on GitHub

GitHub-Status GitHub-Stars GitHub-Commits GitHub-Forks GitHub-Updated

Pull and install in the current directory:

pip install -e git+https://github.com/casperdcl/git-fame.git@master#egg=git-fame

Latest Snapcraft release

Snapcraft

snap install git-fame

Latest Docker release

Docker

docker pull casperdcl/git-fame
docker run --rm casperdcl/git-fame --help
docker run --rm -v </local/path/to/repository>:/repo casperdcl/git-fame

Register alias with git

This is probably not necessary on UNIX systems.

git config --global alias.fame "!python -m gitfame"

Tab completion

Optionally, systems with bash-completion can install tab completion support. The git-fame_completion.bash file needs to be copied to an appropriate folder.

On Ubuntu, the procedure would be:

$ # Ensure completion works for `git` itself
$ sudo apt-get install bash-completion

$ # Install `git fame` completions
$ sudo wget \
    https://raw.githubusercontent.com/casperdcl/git-fame/master/git-fame_completion.bash \
    -O /etc/bash_completion.d/git-fame_completion.bash

followed by a terminal restart.

Changelog

The list of all changes is available on the Releases page: GitHub-Status.

Usage

git fame              # If alias registered with git (see above)
git-fame              # Alternative execution as python console script
python -m gitfame     # Alternative execution as python module
git-fame -h           # Print help

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}$' -twMC

It is also possible to run from within a python shell or script.

>>> import gitfame
>>> gitfame.main(['--sort=commits', '-wt', '/path/to/my/repo'])

Documentation

PyPI-Versions README-Hits

Usage:
  gitfame [--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.
  --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 absoulte (eg: 1970-01-31)
                  or relative to now (eg: 3.weeks).
  --cost=<method>  Include time cost in person-months (COCOMO) or
                   person-hours (based on commit times).
                   Methods: month(s)|cocomo|hour(s)|commit(s).
                   May be multiple comma-separated values.
  -n, --no-regex  Assume <f> are 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].
  --warn-binary   Don't silently skip files which appear to be binary data
                  [default: False].
  -e, --show-email  Show author email instead of name [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].
  --format=<format>        Table format
      [default: pipe]|md|markdown|yaml|yml|json|csv|tsv|tabulate.
      May require `git-fame[<format>]`, e.g. `pip install git-fame[yaml]`.
      Any `tabulate.tabulate_formats` is also accepted.
  --manpath=<path>         Directory in which to install git-fame man pages.
  --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.

Examples

CODEOWNERS

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/CODEOWNERS

Contributions

GitHub-Commits GitHub-Issues GitHub-PRs OpenHub-Status

All source code is hosted on GitHub. Contributions are welcome.

LICENCE

Open Source (OSI approved): LICENCE

Citation information: DOI-URI

Authors

OpenHub-Status

We are grateful for all GitHub-Contributions.

README-Hits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git-fame-1.12.2.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_fame-1.12.2-py2.py3-none-any.whl (16.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file git-fame-1.12.2.tar.gz.

File metadata

  • Download URL: git-fame-1.12.2.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.1

File hashes

Hashes for git-fame-1.12.2.tar.gz
Algorithm Hash digest
SHA256 3e8c193f6633f7d55118123d796fc9a20eb8ce2b472429cb4f1647290274579a
MD5 e280bb6cb4ebc0ab9f69e2a1b4a689da
BLAKE2b-256 37a6f943d39722174f5a1c00950d080e20c4fff47d19d43c5d83f3668ba8d680

See more details on using hashes here.

File details

Details for the file git_fame-1.12.2-py2.py3-none-any.whl.

File metadata

  • Download URL: git_fame-1.12.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.1

File hashes

Hashes for git_fame-1.12.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6aaba24fce51481eedb8367c0d838aa242ead58722d5de91463fe9f07bf70ec8
MD5 7c5b5f00167d65b4484506d23976c9be
BLAKE2b-256 5717b0e22c56a022efe492e3d599f4ef00e06be0923825e004e478f28a31549e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page