mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Ensure that GOBIN is not set when installing a golang hook
If GOBIN is set, it will be used as the install path instead of the first item from GOPATH followed by "/bin". If it is used, commands will not be isolated between different repos.
This commit is contained in:
parent
6bc7b91dd1
commit
fe5390c068
2 changed files with 15 additions and 1 deletions
|
|
@ -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
|
||||
|
|
@ -71,7 +72,7 @@ def _test_hook_repo(
|
|||
path = make_repo(tempdir_factory, repo_path)
|
||||
config = make_config_from_repo(path, **(config_kwargs or {}))
|
||||
ret = _get_hook(config, store, hook_id).run(args)
|
||||
assert ret[0] == expected_return_code
|
||||
assert ret[0] == expected_return_code, "output was: {}".format(ret[1])
|
||||
assert _norm_out(ret[1]) == expected
|
||||
|
||||
|
||||
|
|
@ -267,6 +268,16 @@ 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_hook_repo(
|
||||
tempdir_factory, store, 'golang_hooks_repo',
|
||||
'golang-hook', [], b'hello world\n',
|
||||
)
|
||||
assert os.listdir(gobin_dir) == [], "hook should not be installed in $GOBIN"
|
||||
|
||||
|
||||
def test_rust_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'rust_hooks_repo',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue