Use in_git_dir in more places

This commit is contained in:
Anthony Sottile 2018-12-27 18:02:14 -08:00
parent 2af0b0b4f3
commit d46bbc486f
7 changed files with 88 additions and 143 deletions

View file

@ -421,17 +421,14 @@ def test_replace_old_commit_script(tempdir_factory, store):
assert NORMAL_PRE_COMMIT_RUN.match(output)
def test_uninstall_doesnt_remove_not_our_hooks(tempdir_factory):
path = git_dir(tempdir_factory)
with cwd(path):
mkdirp(os.path.join(path, '.git/hooks'))
with io.open(os.path.join(path, '.git/hooks/pre-commit'), 'w') as f:
f.write('#!/usr/bin/env bash\necho 1\n')
make_executable(f.name)
def test_uninstall_doesnt_remove_not_our_hooks(in_git_dir):
pre_commit = in_git_dir.join('.git/hooks').ensure_dir().join('pre-commit')
pre_commit.write('#!/usr/bin/env bash\necho 1\n')
make_executable(pre_commit.strpath)
assert uninstall() == 0
assert uninstall() == 0
assert os.path.exists(os.path.join(path, '.git/hooks/pre-commit'))
assert pre_commit.exists()
PRE_INSTALLED = re.compile(