prevent infinite recursion of post-checkout on clone

This commit is contained in:
Anthony Sottile 2020-06-09 09:45:40 -07:00
parent 2f25085d60
commit 6ee9e13b26
2 changed files with 7 additions and 1 deletions

View file

@ -158,7 +158,8 @@ def init_repo(path: str, remote: str) -> None:
remote = os.path.abspath(remote) remote = os.path.abspath(remote)
env = no_git_env() 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) cmd_output_b('git', 'remote', 'add', 'origin', remote, cwd=path, env=env)

View file

@ -186,3 +186,8 @@ def test_no_git_env():
'GIT_SSH': '/usr/bin/ssh', 'GIT_SSH': '/usr/bin/ssh',
'GIT_SSH_COMMAND': 'ssh -o', '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()