Skip to content

Commit

Permalink
bump version, merge pull request #88 from casperdcl/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Mar 9, 2023
2 parents 606ecb2 + 2db5f8b commit b18ffe2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ jobs:
if [[ $GITHUB_REF == refs/tags/v* ]]; then
echo docker_tags=latest,${GITHUB_REF/refs\/tags\/v/} >> $GITHUB_OUTPUT
echo snap_channel=stable,candidate,edge >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/master ]]; then
echo docker_tags=master >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo docker_tags=main >> $GITHUB_OUTPUT
echo snap_channel=candidate,edge >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/heads/devel ]]; then
echo docker_tags=devel >> $GITHUB_OUTPUT
Expand Down
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Pull and install:

.. code:: sh
pip install "git+https://github.com/casperdcl/git-fame.git@master#egg=git-fame"
pip install "git+https://github.com/casperdcl/git-fame.git@main#egg=git-fame"
Latest Conda release
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -117,7 +117,7 @@ Tab completion

Optionally, systems with ``bash-completion`` can install tab completion
support. The
`git-fame_completion.bash <https://raw.githubusercontent.com/casperdcl/git-fame/master/git-fame_completion.bash>`__
`git-fame_completion.bash <https://raw.githubusercontent.com/casperdcl/git-fame/main/git-fame_completion.bash>`__
file needs to be copied to an appropriate folder.

On Ubuntu, the procedure would be:
Expand All @@ -129,7 +129,7 @@ On Ubuntu, the procedure would be:
$ # Install `git fame` completions
$ sudo wget \
https://raw.githubusercontent.com/casperdcl/git-fame/master/git-fame_completion.bash \
https://raw.githubusercontent.com/casperdcl/git-fame/main/git-fame_completion.bash \
-O /etc/bash_completion.d/git-fame_completion.bash
followed by a terminal restart.
Expand Down Expand Up @@ -327,11 +327,11 @@ We are grateful for all |GitHub-Contributions|.

|README-Hits|

.. |Build-Status| image:: https://img.shields.io/github/actions/workflow/status/casperdcl/git-fame/test.yml?branch=master&label=git-fame&logo=GitHub
.. |Build-Status| image:: https://img.shields.io/github/actions/workflow/status/casperdcl/git-fame/test.yml?branch=main&label=git-fame&logo=GitHub
:target: https://github.com/casperdcl/git-fame/actions/workflows/test.yml
.. |Coverage-Status| image:: https://img.shields.io/coveralls/github/casperdcl/git-fame/master?logo=coveralls
.. |Coverage-Status| image:: https://img.shields.io/coveralls/github/casperdcl/git-fame/main?logo=coveralls
:target: https://coveralls.io/github/casperdcl/git-fame
.. |Branch-Coverage-Status| image:: https://codecov.io/gh/casperdcl/git-fame/branch/master/graph/badge.svg
.. |Branch-Coverage-Status| image:: https://codecov.io/gh/casperdcl/git-fame/branch/main/graph/badge.svg
:target: https://codecov.io/gh/casperdcl/git-fame
.. |Codacy-Grade| image:: https://api.codacy.com/project/badge/Grade/bde789ee0e57491eb2bb8609bd4190c3
:target: https://www.codacy.com/app/casper-dcl/git-fame/dashboard
Expand Down Expand Up @@ -372,7 +372,7 @@ We are grateful for all |GitHub-Contributions|.
.. |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?color=purple&logo=SPDX
:target: https://raw.githubusercontent.com/casperdcl/git-fame/master/LICENCE
:target: https://raw.githubusercontent.com/casperdcl/git-fame/main/LICENCE
.. |DOI-URI| image:: https://img.shields.io/badge/DOI-10.5281/zenodo.2544975-blue.svg?color=purple&logo=ORCID
:target: https://doi.org/10.5281/zenodo.2544975
.. |README-Hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=git-fame&style=social&r=https://github.com/casperdcl/git-fame
Expand Down
42 changes: 20 additions & 22 deletions gitfame/_gitfame.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
__version__ = get_version(root='..', relative_to=__file__)
except (ImportError, LookupError):
__version__ = "UNKNOWN"
__author__ = "Casper da Costa-Luis <casper@caspersci.uk.to>"
__author__ = "Casper da Costa-Luis <casper.dcl@physics.org>"
__date__ = "2016-2023"
__licence__ = "[MPLv2.0](https://mozilla.org/MPL/2.0/)"
__all__ = ["main"]
Expand Down Expand Up @@ -107,11 +107,11 @@

def hours(dates, maxCommitDiffInSec=120 * 60, firstCommitAdditionInMinutes=120):
"""
Convert list of commit times (in seconds) to an estimate of hours spent.
Convert list of commit times (in seconds) to an estimate of hours spent.
https://github.com/kimmobrunfeldt/git-hours/blob/\
https://github.com/kimmobrunfeldt/git-hours/blob/\
8aaeee237cb9d9028e7a2592a25ad8468b1f45e4/index.js#L114-L143
"""
"""
dates = sorted(dates)
diffInSec = [i - j for (i, j) in zip(dates[1:], dates[:-1])]
res = sum(filter(lambda i: i < maxCommitDiffInSec, diffInSec))
Expand All @@ -121,9 +121,9 @@ def hours(dates, maxCommitDiffInSec=120 * 60, firstCommitAdditionInMinutes=120):
def tabulate(auth_stats, stats_tot, sort='loc', bytype=False, backend='md', cost=None,
row_nums=False):
"""
backends : [default: md]|yaml|json|csv|tsv|tabulate|
`in tabulate.tabulate_formats`
"""
backends : [default: md]|yaml|json|csv|tsv|tabulate|
`in tabulate.tabulate_formats`
"""
COL_NAMES = ['Author', 'loc', 'coms', 'fils', ' distribution']
it_as = getattr(auth_stats, 'iteritems', auth_stats.items)
# get ready
Expand Down Expand Up @@ -193,8 +193,8 @@ def tabulate(auth_stats, stats_tot, sort='loc', bytype=False, backend='md', cost
else:
import tabulate as tabber
if backend not in tabber.tabulate_formats:
raise ValueError("Unknown backend:%s" % backend)
log.debug("backend:tabulate:" + backend)
raise ValueError(f"Unknown backend:{backend}")
log.debug("backend:tabulate:%s", backend)
COL_LENS = [max(len(Str(i[j])) for i in [COL_NAMES] + tab) for j in range(len(COL_NAMES))]
COL_LENS[0] = min(TERM_WIDTH - sum(COL_LENS[1:]) - len(COL_LENS) * 3 - 4, COL_LENS[0])
tab = [[i[0][:COL_LENS[0]]] + i[1:] for i in tab]
Expand All @@ -208,11 +208,10 @@ def _get_auth_stats(gitdir, branch="HEAD", since=None, include_files=None, exclu
silent_progress=False, ignore_whitespace=False, M=False, C=False,
warn_binary=False, bytype=False, show_email=False, prefix_gitdir=False,
churn=None, ignore_rev="", ignore_revs_file=None):
"""Returns dict: {"<author>": {"loc": int, "files": {}, "commits": int,
"ctimes": [int]}}"""
"""Returns dict: {"<author>": {"loc": int, "files": {}, "commits": int, "ctimes": [int]}}"""
since = ["--since", since] if since else []
git_cmd = ["git", "-C", gitdir]
log.debug("base command:" + ' '.join(git_cmd))
log.debug("base command:%s", ' '.join(git_cmd))
file_list = check_output(git_cmd + ["ls-files", "--with-tree", branch]).strip().split('\n')
if not hasattr(include_files, 'search'):
file_list = [
Expand All @@ -222,7 +221,7 @@ def _get_auth_stats(gitdir, branch="HEAD", since=None, include_files=None, exclu
file_list = [
i for i in file_list if include_files.search(i)
if not (exclude_files and exclude_files.search(i))]
log.log(logging.NOTSET, "files:\n" + '\n'.join(file_list))
log.log(logging.NOTSET, "files:\n%s", '\n'.join(file_list))
churn = churn or set()

if churn & CHURN_SLOC:
Expand Down Expand Up @@ -265,7 +264,6 @@ def stats_append(fname, auth, loc, tstamp):
if churn & CHURN_SLOC:
for fname in tqdm(file_list, desc=gitdir if prefix_gitdir else "Processing",
disable=silent_progress, unit="file"):

if prefix_gitdir:
fname = path.join(gitdir, fname)
try:
Expand All @@ -275,12 +273,12 @@ def stats_append(fname, auth, loc, tstamp):
continue
log.log(logging.NOTSET, blame_out)

# Strip boundary messages,
# preventing user with nearest commit to boundary owning the LOC
blame_out = RE_BLAME_BOUNDS.sub('', blame_out)
loc_auth_times = RE_AUTHS_BLAME.findall(blame_out)
if since:
# Strip boundary messages,
# preventing user with nearest commit to boundary owning the LOC
blame_out = RE_BLAME_BOUNDS.sub('', blame_out)

for loc, auth, tstamp in loc_auth_times: # for each chunk
for loc, auth, tstamp in RE_AUTHS_BLAME.findall(blame_out): # for each chunk
loc = int(loc)
stats_append(fname, auth, loc, tstamp)

Expand Down Expand Up @@ -312,7 +310,7 @@ def stats_append(fname, auth, loc, tstamp):
stats_append(fname, auth, loc, tstamp)

# quickly count commits (even if no surviving loc)
log.log(logging.NOTSET, "authors:" + '; '.join(auth_stats.keys()))
log.log(logging.NOTSET, "authors:%s", '; '.join(auth_stats.keys()))
auth_commits = check_output(git_cmd + ["shortlog", "-s", "-e", branch] + since)
for stats in auth_stats.values():
stats.setdefault("commits", 0)
Expand Down Expand Up @@ -347,7 +345,7 @@ def run(args):
log.debug("parsing args")

if args.sort not in "loc commits files hours months".split():
log.warning("--sort argument (%s) unrecognised\n%s" % (args.sort, __doc__))
log.warning("--sort argument (%s) unrecognised\n%s", args.sort, __doc__)
raise KeyError(args.sort)

if not args.excl:
Expand Down Expand Up @@ -481,7 +479,7 @@ def main(args=None):
fi = resource_filename(__name__, 'git-fame.1')
fo = path.join(args.manpath, 'git-fame.1')
copyfile(fi, fo)
log.info("written:" + fo)
log.info("written:%s", fo)
sys.exit(0)

run(args)
Expand Down
32 changes: 15 additions & 17 deletions gitfame/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
tqdm_std.set_lock(RLock())
tqdm = partial(tqdm_std, lock_args=(False,))

__author__ = "Casper da Costa-Luis <casper@caspersci.uk.to>"
__author__ = "Casper da Costa-Luis <casper.dcl@physics.org>"
__date__ = "2016-2023"
__licence__ = "[MPLv2.0](https://mozilla.org/MPL/2.0/)"
__all__ = [
Expand Down Expand Up @@ -88,30 +88,28 @@ def fext(fn):

def int_cast_or_len(i):
"""
>>> int_cast_or_len(range(10))
10
>>> int_cast_or_len('90 foo')
6
>>> int_cast_or_len('90')
90
"""
>>> int_cast_or_len(range(10))
10
>>> int_cast_or_len('90 foo')
6
>>> int_cast_or_len('90')
90
"""
try:
return int(i)
except ValueError:
return len(i)
except TypeError:
except (ValueError, TypeError):
return len(i)


def Max(it, empty_default=0):
"""
>>> Max(range(10), -1)
9
>>> Max(range(0), -1)
-1
>>> Max(range(10), -1)
9
>>> Max(range(0), -1)
-1
"""
"""
try:
return max(it)
except ValueError as e:
Expand Down
12 changes: 2 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@
# and then run "tox" from this directory.

[tox]
# deprecation warning: py{27,py2,35,36}
envlist=py{27,35,36,37,38,39,310,311,py2,py3}, setup.py, nodeps
envlist=py{37,38,39,310,311,py3}, setup.py, nodeps
isolated_build=True

[gh-actions]
python=
2.7: py27
3.5: py35
3.6: py36
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311
pypy-2.7: pypy2
pypy-3.7: pypy3

[core]
deps=
pytest
py3{5,6}: pytest<7
pytest-cov
pytest-timeout
coverage
Expand All @@ -41,9 +35,7 @@ deps=
tqdm
pyyaml
commands=
py{27,py2}: pytest --cov=argopt --cov-report=xml --cov-report=term -o addopts= -v --tb=short -rxs -W=error --durations=10
py3{5,6}: pytest --cov=argopt --cov-report=xml --cov-report=term -o addopts= -v --tb=short -rxs -W=error --durations=0 --durations-min=0.1
py3{7,8,9,10,11}: pytest --cov=argopt --cov-report=xml --cov-report=term
pytest --cov=argopt --cov-report=xml --cov-report=term
{[core]commands}

[testenv:setup.py]
Expand Down

0 comments on commit b18ffe2

Please sign in to comment.