summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--CHANGELOG.md1
-rw-r--r--README.md11
-rw-r--r--gitlint/cli.py12
-rw-r--r--gitlint/config.py12
-rw-r--r--gitlint/git.py2
-rw-r--r--gitlint/tests/test_cli.py8
-rw-r--r--gitlint/tests/test_display.py9
-rw-r--r--gitlint/tests/test_git.py4
-rw-r--r--gitlint/tests/test_lint.py9
-rwxr-xr-xrun_tests.sh1
11 files changed, 44 insertions, 27 deletions
diff --git a/.travis.yml b/.travis.yml
index ef936f7..5acdd79 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,8 @@
language: python
python:
- "2.7"
+ - "3.4"
+ - "3.5"
install:
- "pip install -r requirements.txt"
- "pip install -r test-requirements.txt"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d9b3400..3a043d1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## v0.6.0dev ##
+- Python 3 support!
- Better error handling when gitlint is executed in a directory that is not a git repository or
when git is not installed.
- Breaking change: exit code behavior has changed. More details in the
diff --git a/README.md b/README.md
index b7d1b55..d473bce 100644
--- a/README.md
+++ b/README.md
@@ -282,10 +282,11 @@ python setup.py --long-description | rst2html.py > output.html
- ```--summary``` option: print out a summary at the end. Contains: number/type or errors
- ```--count``` option: only print out the number of violations
- ```--report```: html report
-- Work on a different git repo than the current directory
-- Documentation site on ```gh-pages``` branch using Jekyll
- - Create animation using [https://asciinema.org/]()
-- Python 3 support
- - Currently blocked on Click: [http://click.pocoo.org/5/python3](http://click.pocoo.org/5/python3)
+- Configuration
+ - Work on a different git repo than the current directory: ```--target``` parameter.
+- Documentation
+ - Documentation site on ```gh-pages``` branch using Jekyll
+ - Create demo using [https://asciinema.org/]()
- Developer convenience:
- More unit tests, always more unit tests
+ - Integration tests
diff --git a/gitlint/cli.py b/gitlint/cli.py
index c4602a2..13fde0b 100644
--- a/gitlint/cli.py
+++ b/gitlint/cli.py
@@ -30,7 +30,7 @@ def get_lint_config(config_path=None):
config = LintConfig.load_from_file(DEFAULT_CONFIG_FILE)
except LintConfigError as e:
- click.echo("Error during config file parsing: {0}".format(e.message))
+ click.echo("Error during config file parsing: {0}".format(str(e)))
exit(CONFIG_ERROR_CODE)
# no config file
@@ -50,7 +50,7 @@ def install_hook(ctx, param, value):
click.echo("Successfully installed gitlint commit-msg hook in {0}\n".format(hooks.COMMIT_MSG_HOOK_DST_PATH))
ctx.exit(0)
except hooks.GitHookInstallerError as e:
- click.echo(e.message, err=True)
+ click.echo(str(e), err=True)
ctx.exit(1)
@@ -63,7 +63,7 @@ def uninstall_hook(ctx, param, value):
click.echo(msg.format(hooks.COMMIT_MSG_HOOK_DST_PATH))
ctx.exit(0)
except hooks.GitHookInstallerError as e:
- click.echo(e.message, err=True)
+ click.echo(str(e), err=True)
ctx.exit(1)
@@ -93,7 +93,7 @@ def cli(config, c, ignore, verbose, silent):
try:
lint_config.apply_config_options(c)
except LintConfigError as e:
- click.echo("Config Error: {}".format(e.message))
+ click.echo("Config Error: {}".format(str(e)))
exit(CONFIG_ERROR_CODE)
# Finally, overwrite with any convenience commandline flags
@@ -103,7 +103,7 @@ def cli(config, c, ignore, verbose, silent):
elif verbose > 0:
lint_config.verbosity = verbose
except LintConfigError as e:
- click.echo("Config Error: {0}".format(e.message))
+ click.echo("Config Error: {0}".format(str(e)))
exit(CONFIG_ERROR_CODE) # return CONFIG_ERROR_CODE on config error
try:
@@ -113,7 +113,7 @@ def cli(config, c, ignore, verbose, silent):
gitcontext = GitContext()
gitcontext.set_commit_msg(sys.stdin.read())
except GitContextError as e:
- click.echo(e.message)
+ click.echo(str(e))
exit(GIT_CONTEXT_ERROR_CODE)
# Apply an additional config that is specified in the gitcontext (= commit message)
diff --git a/gitlint/config.py b/gitlint/config.py
index a648a01..e5bbbc8 100644
--- a/gitlint/config.py
+++ b/gitlint/config.py
@@ -3,10 +3,10 @@ from gitlint import options
try:
# python 2.x
- import ConfigParser
+ from ConfigParser import ConfigParser, Error as ConfigParserError
except ImportError: # pragma: no cover
# python 3.x
- from configparser import ConfigParser # pragma: no cover
+ from configparser import ConfigParser, Error as ConfigParserError # pragma: no cover
from collections import OrderedDict
import re
import os
@@ -106,7 +106,7 @@ class LintConfig(object):
except options.RuleOptionError as e:
raise LintConfigError(
"'{}' is not a valid value for option '{}.{}'. {}.".format(option_value, rule_name_or_id, option_name,
- e.message))
+ str(e)))
def apply_config_from_gitcontext(self, gitcontext):
""" Given a git context, applies config specified in the commit message.
@@ -158,12 +158,12 @@ class LintConfig(object):
raise LintConfigError("Invalid file path: {0}".format(filename))
config = LintConfig(config_path=os.path.abspath(filename))
try:
- parser = ConfigParser.ConfigParser()
+ parser = ConfigParser()
parser.read(filename)
LintConfig._parse_general_section(parser, config)
LintConfig._parse_rule_sections(parser, config)
- except ConfigParser.Error as e:
- raise LintConfigError(e.message)
+ except ConfigParserError as e:
+ raise LintConfigError(str(e))
return config
diff --git a/gitlint/git.py b/gitlint/git.py
index 8379137..e787283 100644
--- a/gitlint/git.py
+++ b/gitlint/git.py
@@ -60,7 +60,7 @@ class GitContext(object):
raise GitContextError(error_msg)
except ErrorReturnCode as e: # Something went wrong while executing the git command
error_msg = e.stderr.strip()
- if "Not a git repository" in error_msg:
+ if b"Not a git repository" in error_msg:
error_msg = "The current directory is not a git repository."
else:
error_msg = "An error occured while executing '{}': {}".format(e.full_cmd, error_msg)
diff --git a/gitlint/tests/test_cli.py b/gitlint/tests/test_cli.py
index c3d336c..a9efe73 100644
--- a/gitlint/tests/test_cli.py
+++ b/gitlint/tests/test_cli.py
@@ -4,9 +4,15 @@ from gitlint import hooks
from gitlint import __version__
from click.testing import CliRunner
from mock import patch
-from StringIO import StringIO
from sh import CommandNotFound
+try:
+ # python 2.x
+ from StringIO import StringIO
+except ImportError:
+ # python 3.x
+ from io import StringIO
+
class CLITests(BaseTestCase):
USAGE_ERROR_CODE = 253
diff --git a/gitlint/tests/test_display.py b/gitlint/tests/test_display.py
index 0597312..2157a13 100644
--- a/gitlint/tests/test_display.py
+++ b/gitlint/tests/test_display.py
@@ -1,10 +1,15 @@
from gitlint.display import Display
from gitlint.config import LintConfig
from gitlint.tests.base import BaseTestCase
-
-from StringIO import StringIO
from mock import patch
+try:
+ # python 2.x
+ from StringIO import StringIO
+except ImportError:
+ # python 3.x
+ from io import StringIO
+
class DisplayTests(BaseTestCase):
def test_v(self):
diff --git a/gitlint/tests/test_git.py b/gitlint/tests/test_git.py
index 475cb51..e1c8e93 100644
--- a/gitlint/tests/test_git.py
+++ b/gitlint/tests/test_git.py
@@ -34,8 +34,8 @@ class GitTests(BaseTestCase):
@patch('gitlint.git.sh')
def test_get_latest_commit_git_error(self, sh):
- sh.git.log.side_effect = ErrorReturnCode("git log -1 --pretty=%B", "",
- "fatal: Not a git repository (or any of the parent directories): .git")
+ err = b"fatal: Not a git repository (or any of the parent directories): .git"
+ sh.git.log.side_effect = ErrorReturnCode("git log -1 --pretty=%B", b"", err)
with self.assertRaisesRegexp(GitContextError, "The current directory is not a git repository."):
GitContext.from_local_repository()
diff --git a/gitlint/tests/test_lint.py b/gitlint/tests/test_lint.py
index fe5c109..300b242 100644
--- a/gitlint/tests/test_lint.py
+++ b/gitlint/tests/test_lint.py
@@ -1,13 +1,16 @@
from gitlint.tests.base import BaseTestCase
-
from gitlint.lint import GitLinter
from gitlint.rules import RuleViolation
from gitlint.config import LintConfig
from gitlint.git import GitContext
-
from mock import patch
-from StringIO import StringIO
+try:
+ # python 2.x
+ from StringIO import StringIO
+except ImportError:
+ # python 3.x
+ from io import StringIO
class RuleOptionTests(BaseTestCase):
diff --git a/run_tests.sh b/run_tests.sh
index 679f28c..267ebb9 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -30,7 +30,6 @@ run_pep8_check(){
run_unit_tests(){
if [ -n "$testargs" ]; then
- testargs="${testargs/.py/}" # remove trailing .py
coverage run -m pytest "$testargs"
else
coverage run -m pytest gitlint