Use a unique origin name to avoid poorly configured git

This commit is contained in:
Anthony Sottile 2020-04-20 10:04:30 -07:00
parent 54fdd6ae5f
commit d503f07d3d

View file

@ -158,8 +158,15 @@ 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)
cmd_output_b('git', 'remote', 'add', 'origin', remote, cwd=path, env=env)
def _git(*cmd: str) -> None:
cmd_output_b('git', *cmd, cwd=path, env=env)
os.makedirs(path, exist_ok=True)
_git('init', '.')
origin = '_pre-commit-origin'
_git('remote', 'add', origin, remote)
_git('remote', 'rename', origin, 'origin')
def commit(repo: str = '.') -> None: