summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Cock <p.j.a.cock@googlemail.com>2017-08-04 11:47:00 +0100
committerPeter Cock <p.j.a.cock@googlemail.com>2017-08-04 11:47:50 +0100
commit9457d84cfda7f9c17d67fa3b95d7b826162ddb00 (patch)
tree88044e0279a944018ee66f38a238d19d16f4d5a8 /src
parent6df26ffd57178e50194aea31b3bf9c572f91fa54 (diff)
downloadflake8-9457d84cfda7f9c17d67fa3b95d7b826162ddb00.tar.gz
Tell user how to configure VCS hooks.
Also fills out the hg install hook docstring. This would close GitLab issue #335.
Diffstat (limited to 'src')
-rw-r--r--src/flake8/main/git.py6
-rw-r--r--src/flake8/main/mercurial.py20
2 files changed, 25 insertions, 1 deletions
diff --git a/src/flake8/main/git.py b/src/flake8/main/git.py
index 3cda3c5..ad55100 100644
--- a/src/flake8/main/git.py
+++ b/src/flake8/main/git.py
@@ -68,6 +68,8 @@ def install():
pre-commit python script in the hooks sub-directory if one does not
already exist.
+ It will also print a message to stdout about how to configure the hook.
+
:returns:
True if successful, False if the git directory doesn't exist.
:rtype:
@@ -105,6 +107,10 @@ def install():
# so that git can actually execute it as a hook.
pre_commit_permissions = stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH
os.chmod(pre_commit_file, pre_commit_permissions)
+
+ print('git pre-commit hook installed, for configuration options see')
+ print('http://flake8.pycqa.org/en/latest/user/using-hooks.html')
+
return True
diff --git a/src/flake8/main/mercurial.py b/src/flake8/main/mercurial.py
index a46f676..c0f5d3e 100644
--- a/src/flake8/main/mercurial.py
+++ b/src/flake8/main/mercurial.py
@@ -46,7 +46,22 @@ def hook(ui, repo, **kwargs):
def install():
- """Ensure that the mercurial hooks are installed."""
+ """Ensure that the mercurial hooks are installed.
+
+ This searches for the ``.hg/hgrc`` configuration file and will add commit
+ and qrefresh hooks to it, if they do not already exist.
+
+ It will also print a message to stdout about how to configure the hook.
+
+ :returns:
+ True if successful, False if the ``.hg/hgrc`` file doesn't exist.
+ :rtype:
+ bool
+ :raises:
+ flake8.exceptions.MercurialCommitHookAlreadyExists
+ flake8.exceptions.MercurialQRefreshHookAlreadyExists
+
+ """
hgrc = find_hgrc(create_if_missing=True)
if hgrc is None:
return False
@@ -80,6 +95,9 @@ def install():
with open(hgrc, 'w') as fd:
hgconfig.write(fd)
+ print('mercurial hooks installed, for configuration options see')
+ print('http://flake8.pycqa.org/en/latest/user/using-hooks.html')
+
return True