Add support for commit-msg git hook

This commit is contained in:
Anthony Sottile 2017-07-22 15:16:12 -07:00
parent a6a4762f0d
commit d0b268c813
9 changed files with 107 additions and 57 deletions

View file

@ -1,6 +1,7 @@
from __future__ import absolute_import
from __future__ import unicode_literals
import collections
import functools
import io
import logging
@ -20,6 +21,7 @@ from pre_commit.util import cmd_output
from pre_commit.util import cwd
from testing.fixtures import git_dir
from testing.fixtures import make_consuming_repo
from testing.fixtures import write_config
@pytest.yield_fixture
@ -92,6 +94,29 @@ def in_conflicting_submodule(tempdir_factory):
yield
@pytest.fixture
def commit_msg_repo(tempdir_factory):
path = git_dir(tempdir_factory)
config = collections.OrderedDict((
('repo', 'local'),
(
'hooks',
[collections.OrderedDict((
('id', 'must-have-signoff'),
('name', 'Must have "Signed off by:"'),
('entry', 'grep -q "Signed off by:"'),
('language', 'system'),
('stages', ['commit-msg']),
))],
),
))
write_config(path, config)
with cwd(path):
cmd_output('git', 'add', '.')
cmd_output('git', 'commit', '-m', 'add hooks')
yield path
@pytest.yield_fixture(autouse=True, scope='session')
def dont_write_to_home_directory():
"""pre_commit.store.Store will by default write to the home directory