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 Dec 20, 2017
2 parents dae29a0 + fbc2a0c commit 42419ab
Show file tree
Hide file tree
Showing 13 changed files with 449 additions and 109 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
branch = True
omit =
gitfame/tests/*
[report]
show_missing = True
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ gitfame/*.py[co]
gitfame/*.c
gitfame/*.so
gitfame/tests/*.py[co]
# build
git_fame.egg-info/
build/
dist/
git_fame.egg-info/
# test
.tox/
.coverage
__pycache__
63 changes: 38 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
sudo: required
dist: trusty
# sudo: required
# dist: trusty
language: python
python: 3.5
matrix:
include:
- python: 2.6
env: TOXENV=py26
- python: 2.7
env: TOXENV=py27
- python: 3.3
env: TOXENV=py33
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: 3.7-dev
env: TOXENV=py37-dev
- python: pypy2.7-5.8.0
env: TOXENV=pypy
- python: pypy3.5-5.8.0
env: TOXENV=pypy3
- python: 3.6
env: TOXENV=flake8
- python: 2.7
env: TOXENV=nodeps
cache:
pip: true
directories:
- $HOME/.cache/pip
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
notifications:
email: false
# branches: # remove travis double-check on pull requests in main repo
# only:
# - master
# - /^\d\.\d+$/
env:
- TOXENV=py26
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=py35
- TOXENV=pypy
# - TOXENV=pypy3
- TOXENV=nodeps
- TOXENV=flake8
before_install:
# fix a crash with multiprocessing on Travis
- sudo rm -rf /dev/shm
- sudo ln -s /run/shm /dev/shm
- pip install codecov
# - sudo rm -rf /dev/shm
# - sudo ln -s /run/shm /dev/shm
# coverage submission packages
- git fetch --tags
install:
- pip install 'coverage<4'
- pip install tox coveralls
- pip install tox
- python setup.py install
script:
- tox
after_success:
- coveralls
- codecov
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Misc
include .coveragerc
include Makefile
include README.rst
include tox.ini
include git-fame_completion.bash

# Test suite
Expand Down
124 changes: 99 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,113 @@
PYFILES = $(addsuffix .py,$(addprefix gitfame/,_gitfame _utils __init__ __main__ $(addprefix tests/test_,gitfame utils)))
# IMPORTANT: for compatibility with `python setup.py make [alias]`, ensure:
# 1. Every alias is preceded by @[+]make (eg: @make alias)
# 2. A maximum of one @make alias or command per line
#
# Sample makefile compatible with `python setup.py make`:
#```
#all:
# @make test
# @make install
#test:
# nosetest
#install:
# python setup.py install
#```

.PHONY: distclean prebuildclean clean test run build release upload
.PHONY:
alltests
all
flake8
test
testnose
testsetup
testcoverage
testtimer
distclean
coverclean
prebuildclean
clean
installdev
install
build
pypimeta
pypi
none
run

alltests:
@+make testcoverage
@+make flake8
@+make testsetup

distclean: prebuildclean clean
@+rm -f $(PYFILES:%.py=%.so)
@+rm -f $(PYFILES:%.py=%.c)
all:
@+make alltests
@+make build

flake8:
@+flake8 --max-line-length=80 --count --statistics --exit-zero gitfame/
@+flake8 --max-line-length=80 --count --statistics --exit-zero .
@+flake8 --max-line-length=80 --count --statistics --exit-zero gitfame/tests/

test:
tox --skip-missing-interpreters

testnose:
nosetests argopt -d -v

testsetup:
python setup.py check --restructuredtext --strict
python setup.py make none

testcoverage:
@make coverclean
nosetests argopt --with-coverage --cover-package=gitfame --cover-erase --cover-min-percentage=80 -d -v

testtimer:
nosetests argopt --with-timer -d -v

distclean:
@+make coverclean
@+make prebuildclean
@+make clean
prebuildclean:
@+rm -rf build/ dist/ git_fame.egg-info/
@+python -c "import shutil; shutil.rmtree('build', True)"
@+python -c "import shutil; shutil.rmtree('dist', True)"
@+python -c "import shutil; shutil.rmtree('git_fame.egg-info', True)"
coverclean:
@+python -c "import os; os.remove('.coverage') if os.path.exists('.coverage') else None"
@+python -c "import shutil; shutil.rmtree('gitfame/__pycache__', True)"
@+python -c "import shutil; shutil.rmtree('gitfame/tests/__pycache__', True)"
clean:
@+rm -f $(PYFILES:%.py=%.pyc) $(PYFILES:%.py=%.pyo)
@+rm -rf .coverage
@+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/tests/*.py[co]')]"

test: flake8 testcoverage testsetup
installdev:
python setup.py develop --uninstall
python setup.py develop

run:
python -Om gitfame
install:
python setup.py install

build: prebuildclean
python setup.py build_ext --inplace
build:
@make prebuildclean
python setup.py sdist --formats=gztar,zip bdist_wheel
# python setup.py sdist --formats=gztar,zip bdist_wheel bdist_wininst
python setup.py bdist_wininst

release: build clean
pypimeta:
python setup.py register

upload: prebuildclean test
python setup.py sdist --formats=gztar,zip bdist_wheel upload
# python setup.py sdist --formats=gztar,zip bdist_wheel bdist_wininst upload
pypi:
twine upload dist/*

testsetup:
python setup.py check --metadata --strict
buildupload:
@make testsetup
@make build
@make pypimeta
@make pypi

testcoverage:
rm -f .coverage # coverage erase
nosetests gitfame --with-coverage --cover-package=gitfame --cover-erase --cover-min-percentage=80 -d -v gitfame/
none:
# used for unit testing

flake8:
@+flake8 --max-line-length=80 --count --statistics --ignore=E111,E114 $(PYFILES)
run:
python -Om gitfame
20 changes: 14 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
gitfame
=======
git-fame
========

|PyPI-Status| |PyPI-Versions|

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

|LICENCE|
|LICENCE| |Donate| |OpenHub-Status|


Pretty-print ``git`` repository collaborators sorted by contributions.
Expand Down Expand Up @@ -152,7 +152,7 @@ Licence
Open Source (OSI approved): |LICENCE|
Copyright (c) 2016 Casper da Costa-Luis.
Copyright (c) 2016-7 Casper da Costa-Luis.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0.
Expand All @@ -163,7 +163,9 @@ at `https://mozilla.org/MPL/2.0/ <https://mozilla.org/MPL/2.0/>`__.
Authors
-------
- Casper da Costa-Luis <casper@caspersci.uk.to>
|OpenHub-Status|
- Casper da Costa-Luis (`@casperdcl <https://github.com/casperdcl/>`__) |Donate|
.. |Build-Status| image:: https://travis-ci.org/casperdcl/git-fame.svg?branch=master
:target: https://travis-ci.org/casperdcl/git-fame
Expand All @@ -177,5 +179,11 @@ 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
.. |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
:target: https://mozilla.org/MPL/2.0/
.. |Codacy-Grade| image:: https://api.codacy.com/project/badge/Grade/bde789ee0e57491eb2bb8609bd4190c3
:target: https://www.codacy.com/app/casper-dcl/git-fame
.. |Donate| image:: https://img.shields.io/badge/gift-donate-dc10ff.svg
:target: https://caspersci.uk.to/donate.html
15 changes: 9 additions & 6 deletions gitfame/_gitfame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Options:
-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.
--excl=<f> Excluded files (default: None).
In no-regex mode, may be a comma-separated list.
Expand Down Expand Up @@ -37,13 +38,13 @@

from ._utils import TERM_WIDTH, int_cast_or_len, Max, fext, _str, tqdm, \
check_output
from ._version import __version__ # NOQA

__author__ = "Casper da Costa-Luis <casper@caspersci.uk.to>"
__date__ = "2016"
__date__ = "2016-7"
__licence__ = "[MPLv2.0](https://mozilla.org/MPL/2.0/)"
__all__ = ["main"]
__copyright__ = ' '.join(("Copyright (c)", __date__, __author__, __licence__))
__version__ = "1.2.0"
__license__ = __licence__ # weird foreign language


Expand Down Expand Up @@ -182,8 +183,10 @@ def run(args):

# ! iterating over files

branch = args["--branch"]
git_cmd = ["git", "-C", gitdir]
file_list = check_output(git_cmd + ["ls-files"]).strip().split('\n')
file_list = check_output(
git_cmd + ["ls-files", "--with-tree", branch]).strip().split('\n')
if args['--no-regex']:
file_list = [i for i in file_list
if (not include_files or (i in include_files))
Expand All @@ -196,13 +199,13 @@ def run(args):

auth_stats = {}
for fname in tqdm(file_list, desc="Blame", disable=args["--silent-progress"]):
git_blame_cmd = git_cmd + ["blame", fname, "--line-porcelain"]
git_blame_cmd = git_cmd + ["blame", "--line-porcelain", branch, fname]
if args["--ignore-whitespace"]:
git_blame_cmd.append("-w")
if args["-M"]:
git_blame_cmd.append("-M")
if args["-C"]:
git_blame_cmd.append("-C")
git_blame_cmd.extend(["-C", "-C"]) # twice to include file creation
try:
blame_out = check_output(git_blame_cmd, stderr=subprocess.STDOUT)
except:
Expand All @@ -227,7 +230,7 @@ def run(args):
auth_stats[auth][fext_key] = 1

# print (auth_stats.keys())
auth_commits = check_output(git_cmd + ["shortlog", "-s", "-e"])
auth_commits = check_output(git_cmd + ["shortlog", "-s", "-e", branch])
it_val_as = getattr(auth_stats, 'itervalues', auth_stats.values)
for stats in it_val_as():
stats.setdefault("commits", 0)
Expand Down
11 changes: 6 additions & 5 deletions gitfame/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
try:
from tqdm import tqdm
except ImportError:
print ('warning | module tqdm not found')
print ('info | install `tqdm` (https://github.com/tqdm/tqdm) for\n' +
' | a realitme progressbar')

def tqdm(*args, **kwargs):
if args:
Expand Down Expand Up @@ -84,13 +85,11 @@ def _environ_cols_windows(fp): # pragma: no cover
import struct
from sys import stdin, stdout

io_handle = None
io_handle = -12 # assume stderr
if fp == stdin:
io_handle = -10
elif fp == stdout:
io_handle = -11
else: # assume stderr
io_handle = -12

h = windll.kernel32.GetStdHandle(io_handle)
csbi = create_string_buffer(22)
Expand Down Expand Up @@ -182,7 +181,9 @@ def int_cast_or_len(i):
"""
try:
return int(i)
except:
except ValueError:
return len(i)
except TypeError:
return len(i)


Expand Down
Loading

0 comments on commit 42419ab

Please sign in to comment.