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 Aug 16, 2019
2 parents 5fdf489 + 72cb28c commit 249db66
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 11 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ matrix:
include:
- python: 2.6
env: TOXENV=py26
dist: trusty
- python: 2.7
env: TOXENV=py27
- python: 3.4
Expand Down
4 changes: 2 additions & 2 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ "metadata": {
{
"title": "git-fame: Pretty-print `git` repository collaborators sorted by contributions",
"keywords": [
"git", "blame", "git-blame", "git-log", "code-analysis", "cost", "loc", "author",
"commit", "shortlog", "ls-files"],
"creators": [
{"name": "da Costa-Luis, Casper O.", "orcid": "0000-0002-7211-1557"}]
}}
}
33 changes: 33 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ Documentation
-w, --ignore-whitespace Ignore whitespace when comparing the parent's
version and the child's to find where the lines
came from [default: False].
-e, --show-email Show author email instead of name [default: False].
-M Detect intra-file line moves and copies [default: False].
-C Detect inter-file line moves and copies [default: False].
--format=<format> Table format
Expand All @@ -194,6 +195,38 @@ If multiple user names and/or emails correspond to the same user, aggregate
``git-fame`` statistics and maintain a ``git`` repository properly by adding a
`.mailmap file <https://git-scm.com/docs/git-blame#_mapping_authors>`_.

Examples
--------

CODEOWNERS
~~~~~~~~~~

Generating
`CODEOWNERS <https://help.github.com/en/articles/about-code-owners>`__:

.. code:: sh
# bash syntax function for current directory git repository
owners(){
for f in $(git ls-files); do
# filename
echo -n "$f "
# author emails if loc distribution >= 30%
git fame -esnwMC --incl "$f" | tr '/' '|' \
| awk -F '|' '(NR>6 && $6>=30) {print $2}' \
| xargs echo
done
}
# print to screen and file
owners | tee .github/CODEOWNERS
# same but with `tqdm` progress for large repos
owners \
| tqdm --total $(git ls-files | wc -l) \
--unit file --desc "Generating CODEOWNERS" \
> .github/CODEOWNERS
Contributions
-------------

Expand Down
2 changes: 1 addition & 1 deletion git-fame_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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 -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 -M -C --format --manpath --log' -- ${cur}))
fi
;;
esac
Expand Down
26 changes: 19 additions & 7 deletions gitfame/_gitfame.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
-s, --silent-progress Suppress `tqdm` [default: False].
--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].
-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 @@ -59,7 +60,7 @@


RE_AUTHS = re.compile(
r'^\w+ \d+ \d+ (\d+)\nauthor (.+?)$.*?committer-time (\d+)',
r'^\w+ \d+ \d+ (\d+)\nauthor (.+?)$.*?\ncommitter-time (\d+)',
flags=re.M | re.DOTALL)
# finds all non-escaped commas
# NB: does not support escaping of escaped character
Expand Down Expand Up @@ -274,14 +275,25 @@ def run(args):
for stats in auth_stats.values():
stats.setdefault("commits", 0)
log.debug(RE_NCOM_AUTH_EM.findall(auth_commits.strip()))
for (ncom, auth, _) in RE_NCOM_AUTH_EM.findall(auth_commits.strip()):
auth2em = {}
for (ncom, auth, em) in RE_NCOM_AUTH_EM.findall(auth_commits.strip()):
auth = _str(auth)
auth2em[auth] = em # TODO: count most used email?
try:
auth_stats[_str(auth)]["commits"] += int(ncom)
auth_stats[auth]["commits"] += int(ncom)
except KeyError:
auth_stats[_str(auth)] = {"loc": 0,
"files": set([]),
"commits": int(ncom),
"ctimes": []}
auth_stats[auth] = {"loc": 0,
"files": set([]),
"commits": int(ncom),
"ctimes": []}
if args.show_email:
# replace author name with email
log.debug(auth2em)
old = auth_stats
auth_stats = {}
for auth, stats in getattr(old, 'iteritems', old.items)():
auth_stats[auth2em[auth]] = stats
del old

stats_tot = dict((k, 0) for stats in auth_stats.values() for k in stats)
log.debug(stats_tot)
Expand Down
2 changes: 1 addition & 1 deletion gitfame/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__all__ = ["__version__"]

# major, minor, patch, -extra
version_info = 1, 9, 1
version_info = 1, 10, 0

# Nice string for the version
__version__ = '.'.join(map(str, version_info))
Expand Down

0 comments on commit 249db66

Please sign in to comment.