mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-12 15:44:17 +00:00
Tell user how to configure VCS hooks.
Also fills out the hg install hook docstring. This would close GitLab issue #335.
This commit is contained in:
parent
6df26ffd57
commit
9457d84cfd
2 changed files with 25 additions and 1 deletions
|
|
@ -68,6 +68,8 @@ def install():
|
||||||
pre-commit python script in the hooks sub-directory if one does not
|
pre-commit python script in the hooks sub-directory if one does not
|
||||||
already exist.
|
already exist.
|
||||||
|
|
||||||
|
It will also print a message to stdout about how to configure the hook.
|
||||||
|
|
||||||
:returns:
|
:returns:
|
||||||
True if successful, False if the git directory doesn't exist.
|
True if successful, False if the git directory doesn't exist.
|
||||||
:rtype:
|
:rtype:
|
||||||
|
|
@ -105,6 +107,10 @@ def install():
|
||||||
# so that git can actually execute it as a hook.
|
# so that git can actually execute it as a hook.
|
||||||
pre_commit_permissions = stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH
|
pre_commit_permissions = stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH
|
||||||
os.chmod(pre_commit_file, pre_commit_permissions)
|
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
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,22 @@ def hook(ui, repo, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def install():
|
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)
|
hgrc = find_hgrc(create_if_missing=True)
|
||||||
if hgrc is None:
|
if hgrc is None:
|
||||||
return False
|
return False
|
||||||
|
|
@ -80,6 +95,9 @@ def install():
|
||||||
with open(hgrc, 'w') as fd:
|
with open(hgrc, 'w') as fd:
|
||||||
hgconfig.write(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
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue