Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support gitconfig from env #2136

Merged
merged 1 commit into from Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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