mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-11 07:14:18 +00:00
Bugfix: get the parser if no vcs found in install_hook
This commit is contained in:
parent
e761600ca5
commit
fafa844dce
1 changed files with 9 additions and 7 deletions
|
|
@ -138,12 +138,14 @@ def _get_files(repo, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def find_vcs():
|
def find_vcs():
|
||||||
if os.path.isdir('.git'):
|
_, git_dir, _ = run('git rev-parse --git-dir')
|
||||||
if not os.path.isdir('.git/hooks'):
|
if git_dir and os.path.isdir(git_dir[0]):
|
||||||
os.mkdir('.git/hooks')
|
if not os.path.isdir(os.path.join(git_dir[0], 'hooks')):
|
||||||
return '.git/hooks/pre-commit'
|
os.mkdir(os.path.join(git_dir[0], 'hooks'))
|
||||||
elif os.path.isdir('.hg'):
|
return os.path.join(git_dir[0], 'hooks', 'pre-commit')
|
||||||
return '.hg/hgrc'
|
_, hg_dir, _ = run('hg root')
|
||||||
|
if hg_dir and os.path.isdir(hg_dir[0]):
|
||||||
|
return os.path.join(hg_dir[0], '.hg', 'hgrc')
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -193,7 +195,7 @@ def install_hook():
|
||||||
vcs = find_vcs()
|
vcs = find_vcs()
|
||||||
|
|
||||||
if not vcs:
|
if not vcs:
|
||||||
p = get_parser()
|
p = get_parser()[0]
|
||||||
sys.stderr.write('Error: could not find either a git or mercurial '
|
sys.stderr.write('Error: could not find either a git or mercurial '
|
||||||
'directory. Please re-run this in a proper '
|
'directory. Please re-run this in a proper '
|
||||||
'repository.')
|
'repository.')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue