Package: git-fame
Pretty-printgitrepository collaborators sorted by contributions.~$gitfame--costhour,month--locinsProcessing:100%|██████████████████████████|1/1[00:00<00:00,2.16repo/s]Totalcommits:1775Totalctimes:2770Totalfiles:461Totalhours:449.7Totalloc:41659Totalmonths:151.0|Author|hrs|mths|loc|coms|fils|distribution||:---------------------|------:|-------:|------:|-------:|-------:|:----------------||CasperdaCosta-Luis|228|108|28572|1314|172|68.6/74.0/37.3||StephenLarroque|28|18|5243|203|25|12.6/11.4/5.4||pgajdos|2|9|2606|2|18|6.3/0.1/3.9||MartinZugnoni|2|5|1656|3|3|4.0/0.2/0.7||KyleAltendorf|7|2|541|31|7|1.3/1.7/1.5||HadrienMary|5|1|469|31|17|1.1/1.7/3.7||RichardSheridan|2|1|437|23|3|1.0/1.3/0.7||GuangshuoChen|3|1|321|18|7|0.8/1.0/1.5||NoamYorav-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|...Thedistributioncolumn is a percentage breakdown ofloc/coms/fils.
(e.g. in the table above, Casper has written surviving code in172/461 = 37.3%of all files).Table of contentsInstallationLatest PyPI stable releaseLatest development release on GitHubLatest Conda releaseLatest Snapcraft releaseLatest Docker releaseRegister alias with gitTab completionChangelogUsageDocumentationFAQsExamplesCODEOWNERSZenodo configContributionsLICENCEAuthorsInstallationLatest PyPI stable releasepipinstallgit-fameLatest development release on GitHubPull and install:pipinstall"git+https://github.com/casperdcl/git-fame.git@main#egg=git-fame"Latest Conda releasecondainstall-cconda-forgegit-fameLatest Snapcraft releasesnapinstallgit-fameLatest Docker releasedockerpullcasperdcl/git-famedockerrun--rmcasperdcl/git-fame--helpdockerrun--rm-v</local/path/to/repository>:/repocasperdcl/git-fameRegister alias with gitOn Windows, run:gitconfig--globalalias.fame"!python -m gitfame"This is probably not necessary on UNIX systems.
Ifgit famedoesn’t work after restarting the terminal on Linux & Mac OS, try (with single quotes):gitconfig--globalalias.fame'!python -m gitfame'Tab completionOptionally, systems withbash-completioncan install tab completion
support. Thegit-fame_completion.bashfile needs to be copied to an appropriate folder.On Ubuntu, the procedure would be:$# Ensure completion works for `git` itself$sudoapt-getinstallbash-completion$# Install `git fame` completions$sudowget\https://raw.githubusercontent.com/casperdcl/git-fame/main/git-fame_completion.bash\-O/etc/bash_completion.d/git-fame_completion.bashfollowed by a terminal restart.ChangelogThe list of all changes is available on the Releases page:.Usagegitfame# If alias registered with git (see above)git-fame# Alternative execution as python console scriptpython-mgitfame# Alternative execution as python modulegit-fame-h# Print helpFor 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:gitfame--incl'\.[cht][puh]{0,2}$'-twMCIt is also possible to run from within a python shell or script.>>>importgitfame>>>gitfame.main(['--sort=commits','-wt','/path/to/my/repo'])DocumentationUsage:
  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.
  --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 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.
                   Alters `--loc` default to imply 'ins' (COCOMO) or
                   'ins,del' (hours).
  -R, --recurse  Recursively find repositories & submodules within <gitdir>.
  -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].
  --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`).
  --ignore-revs-file=<f>   Ignore revisions listed in the given file
                           (requires `--loc=surviving`).
  --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, aggregategit-famestatistics and maintain agitrepository properly by adding a.mailmap file.FAQsOptions such as-w,-M, and-Ccan increase accuracy, but take
longer to compute.Note that specifying--sort=hoursor--sort=monthsrequires--costto be specified appropriately.Note that--cost=months(--cost=COCOMO) approximatesperson-monthsand should be used with--loc=ins.Meanwhile,--cost=hours(--cost=commits) approximatesperson-hours.Extra care should be taken when usinginsand/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.ExamplesCODEOWNERSGeneratingCODEOWNERS:# bash syntax function for current directory git repositoryowners(){forfin$(gitls-files);do# filenameecho-n"$f"# author emails if loc distribution >= 30%gitfame-esnwMC--incl"$f"|tr'/''|'\|awk-F'|''(NR>6 && $6>=30) {print $2}'\|xargsechodone}# print to screen and fileowners|tee.github/CODEOWNERS# same but with `tqdm` progress for large reposowners\|tqdm--total$(gitls-files|wc-l)\--unitfile--desc"Generating CODEOWNERS"\>.github/CODEOWNERSZenodo configGenerating.zenodo.json:gitfame-wMC--formatjson\|jq-c'{creators: [.data[] | {name: .[0]}]}'\|sed-r-e's/(\{"name")/\n    \1/g'-e's/:/: /g'\>.zenodo.jsonContributionsAll source code is hosted onGitHub.
Contributions are welcome.LICENCEOpen Source (OSI approved):Citation information:AuthorsCasper da Costa-Luis (casperdcl)We are grateful for all.