mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 04:50:20 -06:00
Added test for git.no_git_env().
Signed-off-by: Brett Randall <javabrett@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@ def zsplit(s):
|
||||
return []
|
||||
|
||||
|
||||
def no_git_env():
|
||||
def no_git_env(_env=None):
|
||||
# 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
|
||||
@@ -27,8 +27,9 @@ def no_git_env():
|
||||
# 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
|
||||
_env = _env if _env is not None else os.environ
|
||||
return {
|
||||
k: v for k, v in os.environ.items()
|
||||
k: v for k, v in _env.items()
|
||||
if not k.startswith('GIT_') or
|
||||
k in {'GIT_EXEC_PATH', 'GIT_SSH', 'GIT_SSH_COMMAND'}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user