Merge pull request #924 from ashanbrown/unset-gobin

Ensure that GOBIN is unset when installing a golang hook
This commit is contained in:
Anthony Sottile 2019-01-27 18:18:06 -08:00 committed by GitHub
commit 160238220f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -69,6 +69,7 @@ def install_environment(prefix, version, additional_dependencies):
else:
gopath = directory
env = dict(os.environ, GOPATH=gopath)
env.pop('GOBIN', None)
cmd_output('go', 'get', './...', cwd=repo_src_dir, env=env)
for dependency in additional_dependencies:
cmd_output('go', 'get', dependency, cwd=repo_src_dir, env=env)

View file

@ -14,6 +14,7 @@ from pre_commit import five
from pre_commit import parse_shebang
from pre_commit.clientlib import CONFIG_SCHEMA
from pre_commit.clientlib import load_manifest
from pre_commit.envcontext import envcontext
from pre_commit.languages import golang
from pre_commit.languages import helpers
from pre_commit.languages import node
@ -267,6 +268,13 @@ def test_golang_hook(tempdir_factory, store):
)
def test_golang_hook_still_works_when_gobin_is_set(tempdir_factory, store):
gobin_dir = tempdir_factory.get()
with envcontext([('GOBIN', gobin_dir)]):
test_golang_hook(tempdir_factory, store)
assert os.listdir(gobin_dir) == []
def test_rust_hook(tempdir_factory, store):
_test_hook_repo(
tempdir_factory, store, 'rust_hooks_repo',