Skip to content

Commit

Permalink
bump version, merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Feb 2, 2018
2 parents a569a45 + 156c85d commit de1824a
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 88 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ before_install:
# fix a crash with multiprocessing on Travis
# - sudo rm -rf /dev/shm
# - sudo ln -s /run/shm /dev/shm
# coverage submission packages
- git fetch --tags
install:
- pip install tox
Expand Down
10 changes: 10 additions & 0 deletions LICENCE
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/.
6 changes: 5 additions & 1 deletion MANIFEST.in
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
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
none
run

help:
@python setup.py make

alltests:
@+make testcoverage
@+make flake8
Expand Down Expand Up @@ -76,10 +79,11 @@ coverclean:
@+python -c "import shutil; shutil.rmtree('gitfame/__pycache__', True)"
@+python -c "import shutil; shutil.rmtree('gitfame/tests/__pycache__', True)"
clean:
@+python -c "import os; import glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
@+python -c "import os; import glob; [os.remove(i) for i in glob.glob('gitfame/*.py[co]')]"
@+python -c "import os; import glob; [os.remove(i) for i in glob.glob('gitfame/*.c')]"
@+python -c "import os; import glob; [os.remove(i) for i in glob.glob('gitfame/tests/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.c')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.so')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/tests/*.py[co]')]"
toxclean:
@+python -c "import shutil; shutil.rmtree('.tox', True)"

Expand Down Expand Up @@ -113,3 +117,9 @@ none:

run:
python -Om gitfame

git-fame.1: git-fame.1.md
python -m gitfame --help | tail -n+9 | head -n-2 | cat "$<" - |\
sed -r 's/^ (--\S+) (\S+)\s*(.*)$$/\n\\\1=*\2*\n: \3/' |\
sed -r 's/^ (-\S+, -\S+)\s*/\n\1\n: /' |\
pandoc -o "$@" -s -t man
17 changes: 9 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
git-fame
========

Pretty-print ``git`` repository collaborators sorted by contributions.

|PyPI-Status| |PyPI-Versions|

|Build-Status| |Coverage-Status| |Branch-Coverage-Status| |Codacy-Grade|

|LICENCE| |Donate| |OpenHub-Status|


Pretty-print ``git`` repository collaborators sorted by contributions.

.. code:: sh
~$ git fame
Expand All @@ -35,6 +34,7 @@ The ``distribution`` column is a percentage breakdown of the other columns
:backlinks: top
:local:


Installation
------------

Expand Down Expand Up @@ -111,9 +111,7 @@ It is also possible to run from within a python shell or script.
.. code:: python
>>> import gitfame
>>> import sys
>>> sys.argv = ['', '--sort=commits', '-wt', './path/to/my/repo']
>>> gitfame.main()
>>> gitfame.main(['--sort=commits', '-wt', '/path/to/my/repo'])
Documentation
Expand All @@ -131,7 +129,7 @@ Documentation
-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).
Expand All @@ -154,7 +152,7 @@ Licence
Open Source (OSI approved): |LICENCE|
Copyright (c) 2016-7 Casper da Costa-Luis.
Copyright (c) 2016-8 Casper da Costa-Luis.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0.
Expand All @@ -169,6 +167,8 @@ Authors
- Casper da Costa-Luis (`@casperdcl <https://github.com/casperdcl/>`__) |Donate|
|git-fame-hits|
.. |Build-Status| image:: https://travis-ci.org/casperdcl/git-fame.svg?branch=master
:target: https://travis-ci.org/casperdcl/git-fame
.. |Coverage-Status| image:: https://coveralls.io/repos/casperdcl/git-fame/badge.svg?branch=master
Expand All @@ -181,6 +181,7 @@ Authors
:target: https://pypi.python.org/pypi/git-fame
.. |PyPI-Versions| image:: https://img.shields.io/pypi/pyversions/git-fame.svg
:target: https://pypi.python.org/pypi/git-fame
.. |git-fame-hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=git-fame&a=hidden
.. |OpenHub-Status| image:: https://www.openhub.net/p/git-fame/widgets/project_thin_badge?format=gif
:target: https://www.openhub.net/p/git-fame?ref=Thin+badge
.. |LICENCE| image:: https://img.shields.io/pypi/l/git-fame.svg
Expand Down
122 changes: 122 additions & 0 deletions git-fame.1
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>.
34 changes: 34 additions & 0 deletions git-fame.1.md
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: ./]
38 changes: 14 additions & 24 deletions gitfame/_gitfame.py
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:
Expand All @@ -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).
Expand Down Expand Up @@ -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 <casper@caspersci.uk.to>"
Expand Down Expand Up @@ -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__)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit de1824a

Please sign in to comment.