Skip to content

Commit

Permalink
bump version, merge pull request #47 from casperdcl/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Nov 9, 2020
2 parents 0e80dbd + b82c212 commit 948f2cb
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 51 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test
on:
push:
schedule:
- cron: '3 2 1 * *' # M H d m w (monthly at 2:03)
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install
run: |
pip install -U tox
pip install -U .
- name: Test
run: tox
env:
TOXENV: 'flake8,setup.py,nodeps'
test:
strategy:
matrix:
python: [3.4, 3.5, 3.6, 3.8]
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install
run: |
pip install -U tox setuptools_scm
pip install -U .
- name: Test
run: tox -e py${PYVER/./}
env:
PYVER: ${{ matrix.python }}
32 changes: 4 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python
env:
global:
- PIP_CACHE_DIR="$HOME/.cache/pip" # unify pip cache location for all platforms
- TOXENV=py
cache:
pip: true
directories:
Expand All @@ -11,7 +12,6 @@ before_cache:
notifications:
email: false
stages:
- check
- test
- name: deploy
if: repo = casperdcl/git-fame AND NOT type = pull_request
Expand All @@ -20,38 +20,14 @@ jobs:
- stage: test
name: py2.7
python: 2.7
env: TOXENV=py27
- name: py3.4
python: 3.4
env: TOXENV=py34
- name: py3.5
python: 3.5
env: TOXENV=py35
- name: py3.6
python: 3.6
env: TOXENV=py36
- name: py3.7
python: 3.7
env: TOXENV=py37
- name: py3.8
python: 3.8
env: TOXENV=py38
- name: pypy2.7
python: pypy
env: TOXENV=pypy
- name: pypy2
python: pypy2
env: CRYPTOGRAPHY_ALLOW_OPENSSL_102=1
- name: pypy3
python: pypy3
env: TOXENV=pypy3
- stage: check
name: style
python: 3.7
env: TOXENV=flake8
- name: setup
python: 3.7
env: TOXENV=setup.py
- name: nodeps
python: 3.7
env: TOXENV=nodeps
- stage: deploy
name: PyPI and GitHub
python: 3.7
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ Documentation
--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
Expand Down
2 changes: 1 addition & 1 deletion git-fame_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _git_fame()
;;
*)
if [ ${COMP_WORDS[1]} == fame ]; then
COMPREPLY=($(compgen -dW '-h --help -v --version --cost --branch --since --sort --incl --excl -n --no-regex -s --silent-progress --warn-binary -t --bytype -w --ignore-whitespace -e --show-email -M -C --format --manpath --log' -- ${cur}))
COMPREPLY=($(compgen -dW '-h --help -v --version --cost --branch --since --sort --incl --excl -n --no-regex -s --silent-progress --warn-binary -t --bytype -w --ignore-whitespace -e --show-email --enum -M -C --format --manpath --log' -- ${cur}))
fi
;;
esac
Expand Down
16 changes: 9 additions & 7 deletions gitfame/_gitfame.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
--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
Expand Down Expand Up @@ -115,7 +116,7 @@ def hours(dates, maxCommitDiffInSec=120 * 60, firstCommitAdditionInMinutes=120):

def tabulate(
auth_stats, stats_tot, sort='loc', bytype=False, backend='md',
cost=None):
cost=None, row_nums=False):
"""
backends : [default: md]|yaml|json|csv|tsv|tabulate|
`in tabulate.tabulate_formats`
Expand All @@ -133,16 +134,14 @@ def tabulate(
100 * len(s.get('files', [])) / max(1, stats_tot['files'])
))).replace('/100.0/', '/ 100/')]
for (auth, s) in it_as()]
if cost is None:
cost = ''
if cost:
cost = cost.lower()
cost = set(cost.lower().split(','))
stats_tot = dict(stats_tot)
if any(i in cost for i in ['cocomo', 'month']):
if cost & {'cocomo', 'month', 'months'}:
COL_NAMES.insert(1, 'mths')
tab = [i[:1] + [3.2 * (i[1] / 1e3)**1.05] + i[1:] for i in tab]
stats_tot.setdefault('months', '%.1f' % sum(i[1] for i in tab))
if any(i in cost for i in ['commit', 'hour']):
if cost & {'commit', 'commits', 'hour', 'hours'}:
COL_NAMES.insert(1, 'hrs')
tab = [i[:1] + [hours(auth_stats[i[0]]['ctimes'])] + i[1:] for i in tab]

Expand All @@ -153,6 +152,9 @@ def tabulate(
("months", "mths")]:
sort = sort.replace(i, j)
tab.sort(key=lambda i: i[COL_NAMES.index(sort)], reverse=True)
if row_nums:
tab = [[str(i)] + j for i, j in enumerate(tab, 1)]
COL_NAMES.insert(0, '#')

totals = 'Total ' + '\nTotal '.join(
"%s: %s" % i for i in sorted(stats_tot.items())) + '\n'
Expand Down Expand Up @@ -390,7 +392,7 @@ def run(args):

print_unicode(tabulate(
auth_stats, stats_tot,
args.sort, args.bytype, args.format, args.cost))
args.sort, args.bytype, args.format, args.cost, args.enum))


def get_main_parser():
Expand Down
8 changes: 4 additions & 4 deletions gitfame/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import sys
import subprocess
import logging
log = logging.getLogger(__name__) # NOQA

from tqdm import tqdm
from tqdm.utils import _screen_shape_wrapper

try:
# python2
Expand All @@ -17,9 +19,6 @@
_range = range
from io import StringIO
string_types = (str,)

from tqdm import tqdm
from tqdm.utils import _screen_shape_wrapper
try:
from threading import RLock
except ImportError:
Expand All @@ -36,6 +35,7 @@
__copyright__ = ' '.join(("Copyright (c)", __date__, __author__, __licence__))
__license__ = __licence__ # weird foreign language

log = logging.getLogger(__name__)
TERM_WIDTH = _screen_shape_wrapper()(sys.stdout)[0]
if not TERM_WIDTH:
# non interactive pipe
Expand Down
7 changes: 6 additions & 1 deletion gitfame/git-fame.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Automatically generated by Pandoc 1.19.2.1
.\" Automatically generated by Pandoc 1.19.2
.\"
.TH "GIT\-FAME" "1" "2016\-2018" "git\-fame User Manuals" ""
.hy
Expand Down Expand Up @@ -109,6 +109,11 @@ Show author email instead of name [default: False].
.RS
.RE
.TP
.B \-\-enum
Show row numbers [default: False].
.RS
.RE
.TP
.B \-t, \-\-bytype
Show stats per file extension [default: False].
.RS
Expand Down
9 changes: 9 additions & 0 deletions gitfame/tests/tests_gitfame.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ def test_tabulate_tabulate():
raise SkipTest


def test_tabulate_enum():
"""Test --enum tabulate"""
from json import loads
res = loads(_gitfame.tabulate(
auth_stats, stats_tot, backend='json', row_nums=True))
assert res['columns'][0] == '#'
assert [int(i[0]) for i in res['data']] == [1, 2]


def test_tabulate_unknown():
"""Test unknown tabulate format"""
try:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ universal = 1
[flake8]
max-line-length=80
ignore=E111,E114
exclude=.tox,build
exclude=.eggs,.tox,build
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def cythonize(*args, **kwargs):
__licence__ = None
src_dir = os.path.abspath(os.path.dirname(__file__))
main_file = os.path.join(src_dir, 'gitfame', '_gitfame.py')
for l in io_open(main_file, mode='r'):
if l.startswith('__author__'):
__author__ = literal_eval(l.split('=', 1)[1].strip())
elif l.startswith('__licence__'):
__licence__ = literal_eval(l.split('=', 1)[1].strip())
for line in io_open(main_file, mode='r'):
if line.startswith('__author__'):
__author__ = literal_eval(line.split('=', 1)[1].strip())
elif line.startswith('__licence__'):
__licence__ = literal_eval(line.split('=', 1)[1].strip())

# Executing makefile commands if specified
if sys.argv[1].lower().strip() == 'make':
Expand Down
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ deps = {[extra]deps}
[testenv:flake8]
deps = flake8
commands =
flake8 --max-line-length=80 --exclude .tox,build \
--ignore=E111,E114 -j 8 --count --statistics --exit-zero .
flake8 -j 8 --count --statistics .

[testenv:setup.py]
deps =
docutils
pygments
py-make>=0.1.0
commands =
python setup.py check --restructuredtext --metadata --strict
python setup.py make none
{envpython} setup.py check --restructuredtext --metadata --strict
{envpython} setup.py make none

0 comments on commit 948f2cb

Please sign in to comment.