mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-11 15:24:18 +00:00
Fix checking for repo dir without git/hg
This commit is contained in:
parent
8b27711400
commit
4da31aa521
1 changed files with 15 additions and 9 deletions
|
|
@ -155,14 +155,20 @@ def _get_files(repo, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def find_vcs():
|
def find_vcs():
|
||||||
|
try:
|
||||||
_, git_dir, _ = run('git rev-parse --git-dir')
|
_, git_dir, _ = run('git rev-parse --git-dir')
|
||||||
if git_dir and os.path.isdir(git_dir[0]):
|
if git_dir and os.path.isdir(git_dir[0]):
|
||||||
if not os.path.isdir(os.path.join(git_dir[0], 'hooks')):
|
if not os.path.isdir(os.path.join(git_dir[0], 'hooks')):
|
||||||
os.mkdir(os.path.join(git_dir[0], 'hooks'))
|
os.mkdir(os.path.join(git_dir[0], 'hooks'))
|
||||||
return os.path.join(git_dir[0], 'hooks', 'pre-commit')
|
return os.path.join(git_dir[0], 'hooks', 'pre-commit')
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
_, hg_dir, _ = run('hg root')
|
_, hg_dir, _ = run('hg root')
|
||||||
if hg_dir and os.path.isdir(hg_dir[0]):
|
if hg_dir and os.path.isdir(hg_dir[0]):
|
||||||
return os.path.join(hg_dir[0], '.hg', 'hgrc')
|
return os.path.join(hg_dir[0], '.hg', 'hgrc')
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -269,7 +275,7 @@ def install_hook():
|
||||||
p = get_parser()[0]
|
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.\n')
|
||||||
p.print_help()
|
p.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue