-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
262 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
* files: * | ||
MPLv2.0 2015-2018 (c) Casper da Costa-Luis | ||
[casperdcl](https://github.com/casperdcl). | ||
|
||
|
||
Mozilla Public Licence (MPL) v. 2.0 - Exhibit A | ||
----------------------------------------------- | ||
|
||
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
# Misc | ||
include .coveragerc | ||
include LICENCE | ||
include Makefile | ||
include README.rst | ||
include tox.ini | ||
include git-fame_completion.bash | ||
|
||
# Test suite | ||
recursive-include gitfame/tests *.py | ||
|
||
# Examples/Documentation | ||
include README.rst | ||
include git-fame.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
.\" Automatically generated by Pandoc 1.19.2.1 | ||
.\" | ||
.TH "GIT\-FAME" "1" "2017\-2018" "git\-fame User Manuals" "" | ||
.hy | ||
.SH NAME | ||
.PP | ||
git\-fame \- Pretty\-print \f[C]git\f[] repository collaborators sorted | ||
by contributions. | ||
.SH SYNOPSIS | ||
.PP | ||
gitfame [\-\-help | \f[I]options\f[]] [<\f[I]gitdir\f[]>] | ||
.SH DESCRIPTION | ||
.PP | ||
See <https://github.com/casperdcl/git-fame>. | ||
.PP | ||
Probably not necessary on UNIX systems: | ||
.IP | ||
.nf | ||
\f[C] | ||
git\ config\ \-\-global\ alias.fame\ "!python\ \-m\ gitfame" | ||
\f[] | ||
.fi | ||
.PP | ||
For example, to print statistics regarding all source files in a | ||
C++/CUDA repository (\f[C]*.c/h/t(pp),\ *.cu(h)\f[]), carefully handling | ||
whitespace and line copies: | ||
.IP | ||
.nf | ||
\f[C] | ||
git\ fame\ \-\-incl\ \[aq]\\.[cht][puh]{0,2}$\[aq]\ \-twMC | ||
\f[] | ||
.fi | ||
.SH OPTIONS | ||
.TP | ||
.B <gitdir> | ||
[default: ./] | ||
.RS | ||
.RE | ||
.TP | ||
.B \-h, \-\-help | ||
show this help message and exit | ||
.RS | ||
.RE | ||
.TP | ||
.B \-\-sort=\f[I]key\f[] | ||
[default: loc]|commits|files. | ||
.RS | ||
.RE | ||
.TP | ||
.B \-t, \-\-bytype | ||
Show stats per file extension [default: False]. | ||
.RS | ||
.RE | ||
.TP | ||
.B \-M, \-M | ||
Detect intra\-file line moves and copies [default: False]. | ||
.RS | ||
.RE | ||
.TP | ||
.B \-w, \-\-ignore\-whitespace | ||
.IP | ||
.nf | ||
\f[C] | ||
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Ignore\ whitespace\ when\ comparing\ the\ parent\[aq]s\ version | ||
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ and\ the\ child\[aq]s\ to\ find\ where\ the\ lines\ came\ from | ||
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ [default:\ False]. | ||
\f[] | ||
.fi | ||
.RS | ||
.RE | ||
.TP | ||
.B \-\-incl=\f[I]f\f[] | ||
Included files [default: .*]. | ||
See \f[C]\-\-excl\f[] for format. | ||
.RS | ||
.RE | ||
.TP | ||
.B \-s, \-\-silent\-progress | ||
.IP | ||
.nf | ||
\f[C] | ||
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Suppress\ `tqdm`\ [default:\ False]. | ||
\f[] | ||
.fi | ||
.RS | ||
.RE | ||
.TP | ||
.B \-\-branch=\f[I]b\f[] | ||
Branch or tag [default: HEAD]. | ||
.RS | ||
.RE | ||
.TP | ||
.B \-v, \-\-version | ||
show program\[aq]s version number and exit | ||
.RS | ||
.RE | ||
.TP | ||
.B \-C, \-C | ||
Detect inter\-file line moves and copies [default: False]. | ||
.RS | ||
.RE | ||
.TP | ||
.B \-\-excl=\f[I]f\f[] | ||
Excluded files (default: None). | ||
In no\-regex mode, may be a comma\-separated list. | ||
Escape (,) for a literal comma (may require \\, in shell). | ||
.RS | ||
.RE | ||
.TP | ||
.B \-\-log=\f[I]lvl\f[] | ||
FATAL|CRITICAL|ERROR|WARN(ING)|[default: INFO]|DEBUG|NOTSET. | ||
.RS | ||
.RE | ||
.TP | ||
.B \-n, \-\-no\-regex | ||
Assume are comma\-separated exact matches rather than regular | ||
expressions [default: False]. | ||
NB: if regex is enabled \f[C],\f[] is equivalent to \f[C]|\f[]. | ||
.RS | ||
.RE | ||
.SH AUTHORS | ||
Casper da Costa\-Luis <https://github.com/casperdcl>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
% GIT-FAME(1) git-fame User Manuals | ||
% Casper da Costa-Luis <https://github.com/casperdcl> | ||
% 2017-2018 | ||
|
||
# NAME | ||
|
||
git-fame - Pretty-print `git` repository collaborators sorted by contributions. | ||
|
||
# SYNOPSIS | ||
|
||
gitfame [--help | *options*] [<*gitdir*>] | ||
|
||
# DESCRIPTION | ||
|
||
See <https://github.com/casperdcl/git-fame>. | ||
|
||
Probably not necessary on UNIX systems: | ||
|
||
```sh | ||
git config --global alias.fame "!python -m gitfame" | ||
``` | ||
|
||
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: | ||
|
||
```sh | ||
git fame --incl '\.[cht][puh]{0,2}$' -twMC | ||
``` | ||
|
||
# OPTIONS | ||
|
||
\<gitdir> | ||
: [default: ./] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/usr/bin/env python | ||
r""" | ||
Usage: | ||
r"""Usage: | ||
gitfame [--help | options] [<gitdir>] | ||
Arguments: | ||
|
@@ -10,7 +9,7 @@ | |
-h, --help Print this help and exit. | ||
-v, --version Print module version and exit. | ||
--branch=<b> Branch or tag [default: HEAD]. | ||
--sort=<key> Options: [default: loc], files, commits. | ||
--sort=<key> [default: loc]|commits|files. | ||
--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). | ||
|
@@ -40,7 +39,7 @@ | |
tabber = None | ||
|
||
from ._utils import TERM_WIDTH, int_cast_or_len, Max, fext, _str, \ | ||
check_output, tqdm, TqdmStream | ||
check_output, tqdm, TqdmStream, print_unicode | ||
from ._version import __version__ # NOQA | ||
|
||
__author__ = "Casper da Costa-Luis <[email protected]>" | ||
|
@@ -152,10 +151,6 @@ def run(args): | |
|
||
log.debug("parsing args") | ||
|
||
if args.gitdir is None: | ||
args.gitdir = './' | ||
# sys.argv[0][:sys.argv[0].replace('\\','/').rfind('/')] | ||
|
||
if args.sort not in ["loc", "commits", "files"]: | ||
log.warn("--sort argument (" + args.sort + | ||
") unrecognised\n" + __doc__) | ||
|
@@ -216,7 +211,7 @@ def run(args): | |
try: | ||
blame_out = check_output(git_blame_cmd, stderr=subprocess.STDOUT) | ||
except Exception as e: | ||
log.warn(str(e)) | ||
log.warn(fname + ':' + str(e)) | ||
continue | ||
log.log(logging.NOTSET, blame_out) | ||
auths = RE_AUTHS.findall(blame_out) | ||
|
@@ -258,30 +253,25 @@ def run(args): | |
for stats in it_val_as()) | ||
log.debug(stats_tot) | ||
|
||
''' | ||
extns = set() | ||
if args.bytype: | ||
for stats in it_val_as(): | ||
extns.update([fext(i) for i in stats["files"]]) | ||
log.debug(extns) | ||
''' | ||
# TODO: | ||
# extns = set() | ||
# if args.bytype: | ||
# for stats in it_val_as(): | ||
# extns.update([fext(i) for i in stats["files"]]) | ||
# log.debug(extns) | ||
|
||
print('Total ' + '\nTotal '.join("{0:s}: {1:d}".format(k, v) | ||
for (k, v) in sorted(getattr( | ||
stats_tot, 'iteritems', stats_tot.items)()))) | ||
|
||
for c in tabulate(auth_stats, stats_tot, args.sort): | ||
try: | ||
print(c, end='') | ||
except UnicodeEncodeError: | ||
print('?', end='') | ||
print ('') | ||
print_unicode(tabulate(auth_stats, stats_tot, args.sort, args.bytype)) | ||
|
||
|
||
def main(): | ||
def main(args=None): | ||
"""args : list [default: sys.argv[1:]]""" | ||
from argopt import argopt | ||
args = argopt(__doc__ + '\n' + __copyright__, | ||
version=__version__).parse_args() | ||
version=__version__).parse_args(args=args) | ||
logging.basicConfig( | ||
level=getattr(logging, args.log, logging.INFO), | ||
stream=TqdmStream) | ||
|
Oops, something went wrong.