|
7 | 7 |
|
8 | 8 | import pre_commit.constants as C |
9 | 9 | from pre_commit import lang_base |
| 10 | +from pre_commit.commands.install_uninstall import install |
10 | 11 | from pre_commit.envcontext import envcontext |
11 | 12 | from pre_commit.languages import golang |
12 | 13 | from pre_commit.store import _make_local_repo |
| 14 | +from pre_commit.util import cmd_output |
| 15 | +from testing.fixtures import add_config_to_repo |
| 16 | +from testing.fixtures import make_config_from_repo |
13 | 17 | from testing.language_helpers import run_language |
| 18 | +from testing.util import cmd_output_mocked_pre_commit_home |
| 19 | +from testing.util import git_commit |
14 | 20 |
|
15 | 21 |
|
16 | 22 | ACTUAL_GET_DEFAULT_VERSION = golang.get_default_version.__wrapped__ |
@@ -134,3 +140,28 @@ def test_local_golang_additional_deps(tmp_path): |
134 | 140 | def test_golang_hook_still_works_when_gobin_is_set(tmp_path): |
135 | 141 | with envcontext((('GOBIN', str(tmp_path.joinpath('gobin'))),)): |
136 | 142 | test_golang_system(tmp_path) |
| 143 | + |
| 144 | + |
| 145 | +def test_during_commit_all(tmp_path, tempdir_factory, store, in_git_dir): |
| 146 | + hook_dir = tmp_path.joinpath('hook') |
| 147 | + hook_dir.mkdir() |
| 148 | + _make_hello_world(hook_dir) |
| 149 | + hook_dir.joinpath('.pre-commit-hooks.yaml').write_text( |
| 150 | + '- id: hello-world\n' |
| 151 | + ' name: hello world\n' |
| 152 | + ' entry: golang-hello-world\n' |
| 153 | + ' language: golang\n' |
| 154 | + ' always_run: true\n', |
| 155 | + ) |
| 156 | + cmd_output('git', 'init', hook_dir) |
| 157 | + cmd_output('git', 'add', '.', cwd=hook_dir) |
| 158 | + git_commit(cwd=hook_dir) |
| 159 | + |
| 160 | + add_config_to_repo(in_git_dir, make_config_from_repo(hook_dir)) |
| 161 | + |
| 162 | + assert not install(C.CONFIG_FILE, store, hook_types=['pre-commit']) |
| 163 | + |
| 164 | + git_commit( |
| 165 | + fn=cmd_output_mocked_pre_commit_home, |
| 166 | + tempdir_factory=tempdir_factory, |
| 167 | + ) |
0 commit comments