Skip to content

Commit

Permalink
Merge pull request #1497 from pre-commit/no_recurse_clone
Browse files Browse the repository at this point in the history
prevent infinite recursion of post-checkout on clone
  • Loading branch information
asottile committed Jun 9, 2020
2 parents 2f25085 + 6ee9e13 commit 8ffcd38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pre_commit/git.py
Expand Up @@ -158,7 +158,8 @@ def init_repo(path: str, remote: str) -> None:
remote = os.path.abspath(remote)

env = no_git_env()
cmd_output_b('git', 'init', path, env=env)
# avoid the user's template so that hooks do not recurse
cmd_output_b('git', 'init', '--template=', path, env=env)
cmd_output_b('git', 'remote', 'add', 'origin', remote, cwd=path, env=env)


Expand Down
5 changes: 5 additions & 0 deletions tests/git_test.py
Expand Up @@ -186,3 +186,8 @@ def test_no_git_env():
'GIT_SSH': '/usr/bin/ssh',
'GIT_SSH_COMMAND': 'ssh -o',
}


def test_init_repo_no_hooks(tmpdir):
git.init_repo(str(tmpdir), remote='dne')
assert not tmpdir.join('.git/hooks').exists()

0 comments on commit 8ffcd38

Please sign in to comment.