Skip to content

Commit

Permalink
Merge pull request #2136 from emzeat/fix/git_config_env
Browse files Browse the repository at this point in the history
support gitconfig from env
  • Loading branch information
asottile committed Nov 23, 2021
2 parents fbf9648 + 4eb91cd commit 36e9514
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pre_commit/git.py
Expand Up @@ -41,9 +41,10 @@ def no_git_env(
return {
k: v for k, v in _env.items()
if not k.startswith('GIT_') or
k.startswith(('GIT_CONFIG_KEY_', 'GIT_CONFIG_VALUE_')) or
k in {
'GIT_EXEC_PATH', 'GIT_SSH', 'GIT_SSH_COMMAND', 'GIT_SSL_CAINFO',
'GIT_SSL_NO_VERIFY',
'GIT_SSL_NO_VERIFY', 'GIT_CONFIG_COUNT',
}
}

Expand Down
10 changes: 10 additions & 0 deletions tests/git_test.py
Expand Up @@ -227,13 +227,23 @@ def test_no_git_env():
'GIT_SSH': '/usr/bin/ssh',
'GIT_SSH_COMMAND': 'ssh -o',
'GIT_DIR': '/none/shall/pass',
'GIT_CONFIG_KEY_0': 'user.name',
'GIT_CONFIG_VALUE_0': 'anthony',
'GIT_CONFIG_KEY_1': 'user.email',
'GIT_CONFIG_VALUE_1': 'asottile@example.com',
'GIT_CONFIG_COUNT': '2',
}
no_git_env = git.no_git_env(env)
assert no_git_env == {
'http_proxy': 'http://myproxy:80',
'GIT_EXEC_PATH': '/some/git/exec/path',
'GIT_SSH': '/usr/bin/ssh',
'GIT_SSH_COMMAND': 'ssh -o',
'GIT_CONFIG_KEY_0': 'user.name',
'GIT_CONFIG_VALUE_0': 'anthony',
'GIT_CONFIG_KEY_1': 'user.email',
'GIT_CONFIG_VALUE_1': 'asottile@example.com',
'GIT_CONFIG_COUNT': '2',
}


Expand Down

0 comments on commit 36e9514

Please sign in to comment.