mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix #322 by only removing git environment variables while cloning
This commit is contained in:
parent
c16479b94a
commit
495fefd316
6 changed files with 42 additions and 14 deletions
|
|
@ -71,6 +71,20 @@ def shell_escape(arg):
|
|||
return "'" + arg.replace("'", "'\"'\"'".strip()) + "'"
|
||||
|
||||
|
||||
def no_git_env():
|
||||
# Too many bugs dealing with environment variables and GIT:
|
||||
# https://github.com/pre-commit/pre-commit/issues/300
|
||||
# In git 2.6.3 (maybe others), git exports GIT_WORK_TREE while running
|
||||
# pre-commit hooks
|
||||
# In git 1.9.1 (maybe others), git exports GIT_DIR and GIT_INDEX_FILE
|
||||
# while running pre-commit hooks in submodules.
|
||||
# GIT_DIR: Causes git clone to clone wrong thing
|
||||
# GIT_INDEX_FILE: Causes 'error invalid object ...' during commit
|
||||
return dict(
|
||||
(k, v) for k, v in os.environ.items() if not k.startswith('GIT_')
|
||||
)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def tarfile_open(*args, **kwargs):
|
||||
"""Compatibility layer because python2.6"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue