From 29c00faa13b31997d82c443e43d93bd75faac04d Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Mon, 26 Nov 2018 17:52:48 +1000 Subject: [PATCH 1/8] fix travis CI py26 --- tox.ini | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 37ed79b..5e5ed33 100644 --- a/tox.ini +++ b/tox.ini @@ -43,7 +43,10 @@ commands = {[extra]commands} [testenv:py26] deps = - {[coverage]deps} + {[core]deps} + coverage + coveralls==1.2.0 + pycparser==2.18 tqdm tabulate commands = {[coverage]commands} @@ -54,7 +57,7 @@ deps = {[extra]deps} [testenv:flake8] deps = flake8 commands = - flake8 --max-line-length=80 --ignore=E111,E114 --count --statistics --exit-zero . + flake8 --max-line-length=80 -j 8 --ignore=E111,E114 --count --statistics --exit-zero . [testenv:setup.py] deps = From e59cf70b052aeb2aaec70320226ed4a9670246fc Mon Sep 17 00:00:00 2001 From: Johann Mortara Date: Tue, 20 Nov 2018 13:43:57 +0100 Subject: [PATCH 2/8] Corrected loc count --- gitfame/_gitfame.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gitfame/_gitfame.py b/gitfame/_gitfame.py index 57a0b6e..26553d9 100755 --- a/gitfame/_gitfame.py +++ b/gitfame/_gitfame.py @@ -52,7 +52,7 @@ __license__ = __licence__ # weird foreign language -RE_AUTHS = re.compile('^author (.+)$', flags=re.M) +RE_AUTHS = re.compile('\d+ \d+ (\d+)\nauthor (.+)$', flags=re.M) # finds all non-escaped commas # NB: does not support escaping of escaped character RE_CSPILT = re.compile(r'(? Date: Tue, 27 Nov 2018 22:45:38 +1000 Subject: [PATCH 3/8] tidy and fix unicode regression --- gitfame/_gitfame.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gitfame/_gitfame.py b/gitfame/_gitfame.py index 26553d9..297d96a 100755 --- a/gitfame/_gitfame.py +++ b/gitfame/_gitfame.py @@ -52,7 +52,7 @@ __license__ = __licence__ # weird foreign language -RE_AUTHS = re.compile('\d+ \d+ (\d+)\nauthor (.+)$', flags=re.M) +RE_AUTHS = re.compile('^\w+ \d+ \d+ (\d+)\nauthor (.+)$', flags=re.M) # finds all non-escaped commas # NB: does not support escaping of escaped character RE_CSPILT = re.compile(r'(? Date: Tue, 27 Nov 2018 23:05:44 +1000 Subject: [PATCH 4/8] man page updates --- Makefile | 2 +- git-fame.1 | 4 ++-- git-fame.1.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 87a2179..75d4161 100644 --- a/Makefile +++ b/Makefile @@ -121,5 +121,5 @@ run: 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: /' |\ + sed -r 's/^ (-\S+, )(-\S+)\s*/\n\\\1\\\2\n: /' |\ pandoc -o "$@" -s -t man diff --git a/git-fame.1 b/git-fame.1 index c4b796a..b334e46 100644 --- a/git-fame.1 +++ b/git-fame.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pandoc 1.19.2.1 +.\" Automatically generated by Pandoc 2.3.1 .\" .TH "GIT\-FAME" "1" "2016\-2018" "git\-fame User Manuals" "" .hy @@ -97,7 +97,7 @@ Can be absoulte (eg: 1970\-01\-31) or relative to now (eg: 3.weeks). .RE .TP .B \-v, \-\-version -show program\[aq]s version number and exit +show program's version number and exit .RS .RE .TP diff --git a/git-fame.1.md b/git-fame.1.md index 090098e..d11886b 100644 --- a/git-fame.1.md +++ b/git-fame.1.md @@ -8,7 +8,7 @@ git-fame - Pretty-print `git` repository collaborators sorted by contributions. # SYNOPSIS -gitfame [--help | *options*] [<*gitdir*>] +gitfame [\--help | *options*] [<*gitdir*>] # DESCRIPTION From 42eed6975b5e018bf15a76d2f8446237fd2d7653 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 27 Nov 2018 23:16:24 +1000 Subject: [PATCH 5/8] move man to package_data to avoid installation issues --- git-fame.1.md => .git-fame.1.md | 0 Makefile | 2 +- git-fame.1 => gitfame/git-fame.1 | 0 setup.py | 3 +-- 4 files changed, 2 insertions(+), 3 deletions(-) rename git-fame.1.md => .git-fame.1.md (100%) rename git-fame.1 => gitfame/git-fame.1 (100%) diff --git a/git-fame.1.md b/.git-fame.1.md similarity index 100% rename from git-fame.1.md rename to .git-fame.1.md diff --git a/Makefile b/Makefile index 75d4161..1287452 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ none: run: python -Om gitfame -git-fame.1: git-fame.1.md +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\\\2\n: /' |\ diff --git a/git-fame.1 b/gitfame/git-fame.1 similarity index 100% rename from git-fame.1 rename to gitfame/git-fame.1 diff --git a/setup.py b/setup.py index 567478c..ab84cc9 100644 --- a/setup.py +++ b/setup.py @@ -194,8 +194,7 @@ def execute_makefile_commands(commands, alias, verbose=False): provides=['gitfame'], install_requires=['argopt>=0.3.5'], entry_points={'console_scripts': ['git-fame=gitfame:main'], }, - data_files=[('man/man1', ['git-fame.1'])], - package_data={'': ['LICENCE']}, + package_data={'gitfame': ['LICENCE', 'git-fame.1']}, ext_modules=cythonize(["gitfame/_gitfame.py", "gitfame/_utils.py"], nthreads=2), classifiers=[ From 735dc669e7df3cff3df723d6db1777478d7fd541 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 27 Nov 2018 23:16:53 +1000 Subject: [PATCH 6/8] setup.py potential bigfixes --- setup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index ab84cc9..9986513 100644 --- a/setup.py +++ b/setup.py @@ -35,11 +35,12 @@ def cythonize(*args, **kwargs): __author__ = None __licence__ = None __version__ = None -main_file = os.path.join(os.path.dirname(__file__), 'gitfame', '_gitfame.py') +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 any(l.startswith(i) for i in ('__author__', '__licence__')): exec(l) -version_file = os.path.join(os.path.dirname(__file__), 'gitfame', '_version.py') +version_file = os.path.join(src_dir, 'gitfame', '_version.py') with io_open(version_file, mode='r') as fd: exec(fd.read()) @@ -135,8 +136,7 @@ def execute_makefile_commands(commands, alias, verbose=False): if verbose: print("Running command: " + cmd) # Launch the command and wait to finish (synchronized call) - check_call(parsed_cmd, - cwd=os.path.dirname(os.path.abspath(__file__))) + check_call(parsed_cmd, cwd=src_dir) # Main setup.py config # @@ -145,7 +145,7 @@ def execute_makefile_commands(commands, alias, verbose=False): # Executing makefile commands if specified if sys.argv[1].lower().strip() == 'make': # Filename of the makefile - fpath = os.path.join(os.path.dirname(__file__), 'Makefile') + fpath = os.path.join(src_dir, 'Makefile') # Parse the makefile, substitute the aliases and extract the commands commands = parse_makefile_aliases(fpath) @@ -175,7 +175,7 @@ def execute_makefile_commands(commands, alias, verbose=False): # Python package config # README_rst = '' -fndoc = os.path.join(os.path.dirname(__file__), 'README.rst') +fndoc = os.path.join(src_dir, 'README.rst') with io_open(fndoc, mode='r', encoding='utf-8') as fd: README_rst = fd.read() setup( @@ -199,7 +199,7 @@ def execute_makefile_commands(commands, alias, verbose=False): nthreads=2), classifiers=[ # Trove classifiers - # (https://pypi.python.org/pypi?%3Aaction=list_classifiers) + # (https://pypi.org/pypi?%3Aaction=list_classifiers) 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Environment :: MacOS X', From 53e071105a186daed1884baa1546ddf9eebdc210 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 27 Nov 2018 23:33:33 +1000 Subject: [PATCH 7/8] add --manpath option --- gitfame/_gitfame.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gitfame/_gitfame.py b/gitfame/_gitfame.py index 297d96a..f87ce71 100755 --- a/gitfame/_gitfame.py +++ b/gitfame/_gitfame.py @@ -26,6 +26,7 @@ came from [default: False]. -M Detect intra-file line moves and copies [default: False]. -C Detect inter-file line moves and copies [default: False]. + --manpath= Directory in which to install git-fame man pages. --log= FATAL|CRITICAL|ERROR|WARN(ING)|[default: INFO]|DEBUG|NOTSET. """ from __future__ import print_function @@ -285,6 +286,17 @@ def main(args=None): log = logging.getLogger(__name__) log.debug(args) + if args.manpath is not None: + from os import path + from shutil import copyfile + from pkg_resources import resource_filename, Requirement + import sys + fi = resource_filename(Requirement.parse('git-fame'), 'gitfame/git-fame.1') + fo = path.join(args.manpath, 'git-fame.1') + copyfile(fi, fo) + log.info("written:" + fo) + sys.exit(0) + run(args) From b7f4c289aaef21bc9468b46d9d0b0a36b23f52ee Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 27 Nov 2018 23:39:07 +1000 Subject: [PATCH 8/8] add unit tests for --manpath --- gitfame/tests/tests_gitfame.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gitfame/tests/tests_gitfame.py b/gitfame/tests/tests_gitfame.py index c1149fe..2b245d4 100644 --- a/gitfame/tests/tests_gitfame.py +++ b/gitfame/tests/tests_gitfame.py @@ -1,6 +1,9 @@ from __future__ import unicode_literals import sys +from os import path +from shutil import rmtree +from tempfile import mkdtemp # import re # from nose import with_setup # from nose.plugins.skip import SkipTest @@ -99,4 +102,17 @@ def test_main(): ]: main(['-s'] + params) + # test --manpath + tmp = mkdtemp() + man = path.join(tmp, "git-fame.1") + assert not path.exists(man) + try: + main(['--manpath', tmp]) + except SystemExit: + pass + else: + raise SystemExit("Expected system exit") + assert path.exists(man) + rmtree(tmp, True) + sys.argv, sys.stdout, sys.stderr = _SYS_AOE