MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / no_git_env

Function no_git_env

pre_commit/git.py:27–48  ·  view source on GitHub ↗
(_env: Mapping[str, str] | None = None)

Source from the content-addressed store, hash-verified

25
26
27def no_git_env(_env: Mapping[str, str] | None = None) -> dict[str, str]:
28 # Too many bugs dealing with environment variables and GIT:
29 # https://github.com/pre-commit/pre-commit/issues/300
30 # In git 2.6.3 (maybe others), git exports GIT_WORK_TREE while running
31 # pre-commit hooks
32 # In git 1.9.1 (maybe others), git exports GIT_DIR and GIT_INDEX_FILE
33 # while running pre-commit hooks in submodules.
34 # GIT_DIR: Causes git clone to clone wrong thing
35 # GIT_INDEX_FILE: Causes 'error invalid object ...' during commit
36 _env = _env if _env is not None else os.environ
37 return {
38 k: v for k, v in _env.items()
39 if not k.startswith('GIT_') or
40 k.startswith(('GIT_CONFIG_KEY_', 'GIT_CONFIG_VALUE_')) or
41 k in {
42 'GIT_EXEC_PATH', 'GIT_SSH', 'GIT_SSH_COMMAND', 'GIT_SSL_CAINFO',
43 'GIT_SSL_NO_VERIFY', 'GIT_CONFIG_COUNT',
44 'GIT_HTTP_PROXY_AUTHMETHOD',
45 'GIT_ALLOW_PROTOCOL',
46 'GIT_ASKPASS',
47 }
48 }
49
50
51def get_root() -> str:

Callers 3

install_environmentFunction · 0.90
init_repoFunction · 0.85
commitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected