summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-08 12:54:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-08 12:54:48 +0000
commitd7da8ad135cc84931411dbf961ac8576dd73187c (patch)
tree26134c9cf386c41b7424943e0ab7eaa874f66041
parentReleasing debian version 2.10.0-2. (diff)
downloadpre-commit-d7da8ad135cc84931411dbf961ac8576dd73187c.tar.xz
pre-commit-d7da8ad135cc84931411dbf961ac8576dd73187c.zip
Merging upstream version 2.10.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--.pre-commit-config.yaml4
-rw-r--r--CHANGELOG.md8
-rw-r--r--pre_commit/languages/golang.py3
-rw-r--r--setup.cfg2
-rw-r--r--tests/repository_test.py54
5 files changed, 67 insertions, 4 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 321e839..6cc66eb 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -21,11 +21,11 @@ repos:
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/pre-commit
- rev: v2.10.0
+ rev: v2.10.1
hooks:
- id: validate_manifest
- repo: https://github.com/asottile/pyupgrade
- rev: v2.7.4
+ rev: v2.9.0
hooks:
- id: pyupgrade
args: [--py36-plus]
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ba7ffa..c8af449 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+2.10.1 - 2021-02-06
+===================
+
+### Fixes
+- Fix `language: golang` repositories containing recursive submodules
+ - #1788 issue by @gaurav517.
+ - #1789 PR by @paulhfischer.
+
2.10.0 - 2021-01-27
===================
diff --git a/pre_commit/languages/golang.py b/pre_commit/languages/golang.py
index 91ade1e..d6165d9 100644
--- a/pre_commit/languages/golang.py
+++ b/pre_commit/languages/golang.py
@@ -69,7 +69,8 @@ def install_environment(
repo_src_dir = os.path.join(directory, 'src', guess_go_dir(remote))
# Clone into the goenv we'll create
- helpers.run_setup_cmd(prefix, ('git', 'clone', '.', repo_src_dir))
+ cmd = ('git', 'clone', '--recursive', '.', repo_src_dir)
+ helpers.run_setup_cmd(prefix, cmd)
if sys.platform == 'cygwin': # pragma: no cover
_, gopath, _ = cmd_output('cygpath', '-w', directory)
diff --git a/setup.cfg b/setup.cfg
index 913344b..7e4a1c4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = pre_commit
-version = 2.10.0
+version = 2.10.1
description = A framework for managing and maintaining multi-language pre-commit hooks.
long_description = file: README.md
long_description_content_type = text/markdown
diff --git a/tests/repository_test.py b/tests/repository_test.py
index 8540db3..1b58164 100644
--- a/tests/repository_test.py
+++ b/tests/repository_test.py
@@ -10,6 +10,7 @@ import pytest
import re_assert
import pre_commit.constants as C
+from pre_commit import git
from pre_commit.clientlib import CONFIG_SCHEMA
from pre_commit.clientlib import load_manifest
from pre_commit.envcontext import envcontext
@@ -346,6 +347,59 @@ def test_golang_hook_still_works_when_gobin_is_set(tempdir_factory, store):
assert os.listdir(gobin_dir) == []
+def test_golang_with_recursive_submodule(tmpdir, tempdir_factory, store):
+ sub_go = '''\
+package sub
+
+import "fmt"
+
+func Func() {
+ fmt.Println("hello hello world")
+}
+'''
+ sub = tmpdir.join('sub').ensure_dir()
+ sub.join('sub.go').write(sub_go)
+ cmd_output('git', '-C', str(sub), 'init', '.')
+ cmd_output('git', '-C', str(sub), 'add', '.')
+ git.commit(str(sub))
+
+ pre_commit_hooks = '''\
+- id: example
+ name: example
+ entry: example
+ language: golang
+ verbose: true
+'''
+ go_mod = '''\
+module github.com/asottile/example
+
+go 1.14
+'''
+ main_go = '''\
+package main
+
+import "github.com/asottile/example/sub"
+
+func main() {
+ sub.Func()
+}
+'''
+ repo = tmpdir.join('repo').ensure_dir()
+ repo.join('.pre-commit-hooks.yaml').write(pre_commit_hooks)
+ repo.join('go.mod').write(go_mod)
+ repo.join('main.go').write(main_go)
+ cmd_output('git', '-C', str(repo), 'init', '.')
+ cmd_output('git', '-C', str(repo), 'add', '.')
+ cmd_output('git', '-C', str(repo), 'submodule', 'add', str(sub), 'sub')
+ git.commit(str(repo))
+
+ config = make_config_from_repo(str(repo))
+ hook = _get_hook(config, store, 'example')
+ ret, out = _hook_run(hook, (), color=False)
+ assert ret == 0
+ assert _norm_out(out) == b'hello hello world\n'
+
+
def test_rust_hook(tempdir_factory, store):
_test_hook_repo(
tempdir_factory, store, 'rust_hooks_repo',