mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-17 22:40:11 -06: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:
@@ -7,6 +7,7 @@ import sys
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import git
|
||||
from pre_commit.envcontext import envcontext
|
||||
from pre_commit.envcontext import UNSET
|
||||
from pre_commit.envcontext import Var
|
||||
from pre_commit.languages import helpers
|
||||
from pre_commit.util import clean_path_on_failure
|
||||
@@ -21,6 +22,7 @@ healthy = helpers.basic_healthy
|
||||
|
||||
def get_env_patch(venv):
|
||||
return (
|
||||
('GOBIN', UNSET),
|
||||
('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))),
|
||||
)
|
||||
|
||||
@@ -69,6 +71,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)
|
||||
|
||||
Reference in New Issue
Block a user