Merge branch 'pr/47'

This commit is contained in:
Ian Cordasco 2015-12-17 08:38:05 -06:00
commit b50c510970

View file

@ -155,14 +155,22 @@ def _get_files(repo, **kwargs):
def find_vcs():
_, git_dir, _ = run('git rev-parse --git-dir')
if git_dir and os.path.isdir(git_dir[0]):
if not os.path.isdir(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')
_, hg_dir, _ = run('hg root')
if hg_dir and os.path.isdir(hg_dir[0]):
return os.path.join(hg_dir[0], '.hg', 'hgrc')
try:
_, git_dir, _ = run('git rev-parse --git-dir')
except OSError:
pass
else:
if git_dir and os.path.isdir(git_dir[0]):
if not os.path.isdir(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')
try:
_, hg_dir, _ = run('hg root')
except OSError:
pass
else:
if hg_dir and os.path.isdir(hg_dir[0]):
return os.path.join(hg_dir[0], '.hg', 'hgrc')
return ''
@ -269,7 +277,7 @@ def install_hook():
p = get_parser()[0]
sys.stderr.write('Error: could not find either a git or mercurial '
'directory. Please re-run this in a proper '
'repository.')
'repository.\n')
p.print_help()
sys.exit(1)