summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml5
-rw-r--r--CHANGELOG.md7
-rw-r--r--docs/configuration.md15
-rw-r--r--docs/contributing.md3
-rw-r--r--docs/index.md3
-rw-r--r--gitlint/tests/test_cli.py10
-rw-r--r--qa/base.py2
-rwxr-xr-xrun_tests.sh11
8 files changed, 43 insertions, 13 deletions
diff --git a/.travis.yml b/.travis.yml
index 5bb856e..6b60569 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,6 @@
+os:
+ - linux
+ - osx
language: python
python:
- "2.7"
@@ -7,6 +10,6 @@ python:
install:
- "pip install -r requirements.txt"
- "pip install -r test-requirements.txt"
-script: "./run_tests.sh && ./run_tests.sh --integration && ./run_tests.sh --pep8 && gitlint"
+script: "./run_tests.sh && ./run_tests.sh --integration && ./run_tests.sh --pep8 && ./run_tests.sh --git"
after_success:
- coveralls \ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 65f3c63..224e9be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog #
+## v0.7.0dev (master, not released) ##
+
+- Bugfix: commit-msg hook not working properly on linux (#8).
+- Experimental: support for commit-msg hook in SourceTree on OS X (enhancement #7).
+- Development: initial set of integration tests. Test gitlint end-to-end after it is installed.
+- Development: internal refactoring to extract more info from git. This will allow for more complex rules in the future.
+
## v0.6.1 (2015-11-22) ##
- Fix: ```install-hook``` and ```generate-config``` commands not working when gitlint is installed from pypi.
diff --git a/docs/configuration.md b/docs/configuration.md
index 6486d6d..c065520 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -1,10 +1,17 @@
# Config files #
-You can modify gitlint's behavior by specifying a config file like so:
+You can modify gitlint's behavior by adding a ```.gitlint``` file to your git repository.
+
+Generate a default ```.gitlint``` config file by running:
+```bash
+gitlint generate-config
+```
+You can also use a different config file like so:
+
```bash
gitlint --config myconfigfile.ini
```
-By default, gitlint will look for an optional ```.gitlint``` config file.
-Details about rule config options can be found in the [Rules](rules.md) page.
+
+The block below shows a sample ```.gitlint``` file. Details about rule config options can be found on the [Rules](rules.md) page.
```ini
# All these sections are optional, edit this file as you like.
@@ -50,8 +57,6 @@ ignore-merge-commits=false
files=gitlint/rules.py,README.md
```
-Details about rule config options can be found in the Rules page.
-
# Commandline config #
You can also use one or more ```-c``` flags like so:
diff --git a/docs/contributing.md b/docs/contributing.md
index c3aa717..6768e1f 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -21,9 +21,10 @@ To run tests:
```bash
./run_tests.sh # run unit tests and print test coverage
./run_tests.sh --no-coverage # run unit tests without test coverage
-./run_tests.sh --integration # Run integration tests (Requires that you have gitlint installed)
+./run_tests.sh --integration # Run integration tests (requires that you have gitlint installed)
./run_tests.sh --pep8 # pep8 checks
./run_tests.sh --stats # print some code stats
+./run_tests.sh --git # inception: run gitlint against itself
```
To see the package description in HTML format
diff --git a/docs/index.md b/docs/index.md
index 3b1107b..898fd2b 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -9,7 +9,8 @@ Many of the gitlint validations are based on
[well-known](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
[community](http://addamhardy.com/blog/2013/06/05/good-commit-messages-and-enforcing-them-with-git-hooks/),
[standards](http://chris.beams.io/posts/git-commit/), others are based on checks that we've found
-useful throughout the years. Gitlint has sane defaults, but you can also easily customize it to your own liking.
+useful throughout the years. Gitlint has sane defaults, but
+[you can also easily customize it to your own liking](configuration.md).
Gitlint supports both python 2.7 and python 3.3+.
If you are looking for an alternative written in Ruby, have a look at
diff --git a/gitlint/tests/test_cli.py b/gitlint/tests/test_cli.py
index 2f9f991..a714fb7 100644
--- a/gitlint/tests/test_cli.py
+++ b/gitlint/tests/test_cli.py
@@ -68,7 +68,8 @@ class CLITests(BaseTestCase):
# We expect gitlint to tell us that /tmp is not a git repo (this proves that it takes the target parameter
# into account).
self.assertEqual(result.exit_code, self.GIT_CONTEXT_ERROR_CODE)
- self.assertEqual(result.output, "/tmp is not a git repository.\n")
+ expected_path = os.path.realpath("/tmp")
+ self.assertEqual(result.output, "%s is not a git repository.\n" % expected_path)
def test_target_negative(self):
# try setting a non-existing target
@@ -140,10 +141,11 @@ class CLITests(BaseTestCase):
# Specified target
install_hook.reset_mock()
result = self.cli.invoke(cli.cli, ["--target", "/tmp", "install-hook"])
- expected = "Successfully installed gitlint commit-msg hook in /tmp/.git/hooks/commit-msg\n"
+ expected_path = os.path.realpath("/tmp/.git/hooks/commit-msg")
+ expected = "Successfully installed gitlint commit-msg hook in %s\n" % expected_path
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output, expected)
- install_hook.assert_called_once_with(config.LintConfig(target="/tmp"))
+ install_hook.assert_called_once_with(config.LintConfig(target=os.path.realpath("/tmp")))
@patch('gitlint.hooks.GitHookInstaller.install_commit_msg_hook', side_effect=hooks.GitHookInstallerError("test"))
def test_install_hook_negative(self, install_hook):
@@ -155,7 +157,7 @@ class CLITests(BaseTestCase):
@patch('gitlint.hooks.GitHookInstaller.uninstall_commit_msg_hook')
def test_uninstall_hook(self, uninstall_hook):
result = self.cli.invoke(cli.cli, ["uninstall-hook"])
- expected_path = os.path.join(os.getcwd(), hooks.COMMIT_MSG_HOOK_DST_PATH)
+ expected_path = os.path.realpath(os.path.join(os.getcwd(), hooks.COMMIT_MSG_HOOK_DST_PATH))
expected = "Successfully uninstalled gitlint commit-msg hook from {0}\n".format(expected_path)
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output, expected)
diff --git a/qa/base.py b/qa/base.py
index 2d959cf..a09b7f7 100644
--- a/qa/base.py
+++ b/qa/base.py
@@ -13,7 +13,7 @@ class BaseTestCase(TestCase):
@classmethod
def setUpClass(cls):
""" Sets up the integration tests by creating a new temporary git repository """
- cls.tmp_git_repo = "/tmp/gitlint-test-%s" % datetime.now().strftime("%Y%m%d-%H%M%S")
+ cls.tmp_git_repo = os.path.realpath("/tmp/gitlint-test-%s" % datetime.now().strftime("%Y%m%d-%H%M%S"))
git("init", cls.tmp_git_repo)
# configuring name and email is required in every git repot
git("config", "user.name", "gitlint-test-user", _cwd=cls.tmp_git_repo)
diff --git a/run_tests.sh b/run_tests.sh
index ac82a36..4573cac 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -54,6 +54,11 @@ run_integration_tests(){
fi
}
+run_git_check(){
+ echo "Running gitlint..."
+ gitlint
+}
+
run_stats(){
echo "*** Code ***"
radon raw -s gitlint | tail -n 6
@@ -67,6 +72,7 @@ run_stats(){
# default behavior
just_pep8=0
just_lint=0
+just_git=0
just_integration_tests=0
just_stats=0
include_coverage=1
@@ -77,6 +83,7 @@ while [ "$#" -gt 0 ]; do
-h|--help) shift; help;;
-p|--pep8) shift; just_pep8=1;;
-l|--lint) shift; just_lint=1;;
+ -g|--git) shift; just_git=1;;
-s|--stats) shift; just_stats=1;;
-i|--integration) shift; just_integration_tests=1;;
--no-coverage)shift; include_coverage=0;;
@@ -99,5 +106,9 @@ if [ $just_integration_tests -eq 1 ]; then
exit $?
fi
+if [ $just_git -eq 1 ]; then
+ run_git_check
+ exit $?
+fi
run_unit_tests || exit