MCPcopy
hub / github.com/copier-org/copier / test_commit_hooks_respected

Function test_commit_hooks_respected

tests/test_updatediff.py:313–482  ·  view source on GitHub ↗

Commit hooks are taken into account when producing the update diff.

(tmp_path_factory: pytest.TempPathFactory)

Source from the content-addressed store, hash-verified

311)
312@pytest.mark.impure
313def test_commit_hooks_respected(tmp_path_factory: pytest.TempPathFactory) -> None:
314 """Commit hooks are taken into account when producing the update diff."""
315 # Prepare source template v1
316 src, dst1, dst2 = map(tmp_path_factory.mktemp, ("src", "dst1", "dst2"))
317 with local.cwd(src):
318 build_file_tree(
319 {
320 "copier.yml": (
321 f"""
322 _envops: {BRACKET_ENVOPS_JSON}
323 _templates_suffix: {SUFFIX_TMPL}
324 _tasks:
325 - git init
326 - pre-commit install -t pre-commit -t commit-msg
327 - pre-commit run -a || true
328 what: grog
329 """
330 ),
331 "[[ _copier_conf.answers_file ]].tmpl": (
332 """
333 [[ _copier_answers|to_nice_yaml ]]
334 """
335 ),
336 ".pre-commit-config.yaml": (
337 r"""
338 repos:
339 - repo: https://github.com/pre-commit/mirrors-prettier
340 rev: v2.0.4
341 hooks:
342 - id: prettier
343 - repo: https://github.com/commitizen-tools/commitizen
344 rev: v3.12.0
345 hooks:
346 - id: commitizen
347 - repo: local
348 hooks:
349 - id: forbidden-files
350 name: forbidden files
351 entry: found forbidden files; remove them
352 language: fail
353 files: "\\.rej$"
354 """
355 ),
356 "life.yml.tmpl": (
357 """
358 # Following code should be reformatted by pre-commit after copying
359 Line 1: hello
360 Line 2: [[ what ]]
361 Line 3: bye
362 """
363 ),
364 }
365 )
366 git("init")
367 git("add", ".")
368 git("commit", "-m", "feat: commit 1")
369 git("tag", "v1")
370 # Copy source template

Callers

nothing calls this directly

Calls 3

run_copyFunction · 0.90
run_updateFunction · 0.90
build_file_treeFunction · 0.85

Tested by

no test coverage detected