mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
Use a unique origin name to avoid poorly configured git
This commit is contained in:
parent
54fdd6ae5f
commit
d503f07d3d
1 changed files with 9 additions and 2 deletions
|
|
@ -158,8 +158,15 @@ 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)
|
|
||||||
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:
|
def commit(repo: str = '.') -> None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue