summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Stapleton Cordasco <graffatcolmingov@gmail.com>2017-08-07 10:56:37 +0000
committerIan Stapleton Cordasco <graffatcolmingov@gmail.com>2017-08-07 10:56:37 +0000
commit1f0e6a6ffa4a9405909b27ccee163ce467512aaa (patch)
treeb25f224a9bcc6583878fb0be68480494693b40f3 /src
parent1820afa4a44a9221bee62fe2fd90207850a82216 (diff)
parent12660a6fb7a4625a45ee17f3da8d9ccd9df30ad3 (diff)
downloadflake8-1f0e6a6ffa4a9405909b27ccee163ce467512aaa.tar.gz
Merge branch 'hook_conf' into 'master'
Tell user how to configure VCS hooks See merge request !198
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..344c9f7 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
+ :raises:
+ 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