(_env: Mapping[str, str] | None = None)
| 25 | |
| 26 | |
| 27 | def 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 | |
| 51 | def get_root() -> str: |
no outgoing calls
no test coverage detected