Repository: copier-org/copier
Pull request #1688 (2024-07-02 15:00:41)

fix: Missing passing of `skip_tasks` flag
Couldn't get the `--skip-flags` option working until I passed the option to the worker.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/copier-org/copier/pull/1688?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 92.68%. Comparing base [(`3f89b71`)](https://app.codecov.io/gh/copier-org/copier/commit/3f89b71cc6116e2f6dcda3ceb3ce4a41301895b8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org) to head [(`4370c33`)](https://app.codecov.io/gh/copier-org/copier/commit/4370c33b27289d03783f59b91eaa0481d0e51f6f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #1688      +/-   ##
==========================================
- Coverage   97.59%   92.68%   -4.91%     
==========================================
  Files          49       49              
  Lines        4993     4993              
==========================================
- Hits         4873     4628     -245     
- Misses        120      365     +245     
```

| [Flag](https://app.codecov.io/gh/copier-org/copier/pull/1688/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/copier-org/copier/pull/1688/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org) | `92.68% <ø> (-4.91%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/copier-org/copier/pull/1688?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org).

arnaubt: @sisp Sure enough, test added! Let me know if it's good enough.
arnaubt: Test moved and suggestions applied, thanks!

Patch:
diff --git a/copier/cli.py b/copier/cli.py
index 3614304..e1dfb40 100644
--- a/copier/cli.py
+++ b/copier/cli.py
@@ -222,6 +222,7 @@ class _Subcommand(cli.Application):  # type: ignore[misc]
             vcs_ref=self.vcs_ref,
             use_prereleases=self.prereleases,
             unsafe=self.unsafe,
+            skip_tasks=self.skip_tasks,
             **kwargs,
         )
 


Test patch:
diff --git a/tests/test_tasks.py b/tests/test_tasks.py
index 05c80b2..1cd954b 100644
--- a/tests/test_tasks.py
+++ b/tests/test_tasks.py
@@ -4,8 +4,10 @@ from pathlib import Path
 from typing import Literal
 
 import pytest
+import yaml
 
 import copier
+from copier.cli import CopierApp
 
 from .helpers import BRACKET_ENVOPS_JSON, SUFFIX_TMPL, build_file_tree
 
@@ -82,6 +84,23 @@ def test_copy_skip_tasks(template_path: str, tmp_path: Path) -> None:
     assert not (tmp_path / "pyfile").is_file()
 
 
+@pytest.mark.parametrize("skip_tasks", [False, True])
+def test_copy_cli_skip_tasks(
+    tmp_path_factory: pytest.TempPathFactory,
+    skip_tasks: bool,
+) -> None:
+    src, dst = map(tmp_path_factory.mktemp, ["src", "dst"])
+    build_file_tree(
+        {(src / "copier.yaml"): yaml.safe_dump({"_tasks": ["touch task.txt"]})}
+    )
+    _, retcode = CopierApp.run(
+        ["copier", "copy", "--UNSAFE", *(["--skip-tasks"] if skip_tasks else []), str(src), str(dst)],
+        exit=False,
+    )
+    assert retcode == 0
+    assert (dst / "task.txt").exists() is (not skip_tasks)
+
+
 def test_pretend_mode(tmp_path_factory: pytest.TempPathFactory) -> None:
     src, dst = map(tmp_path_factory.mktemp, ("src", "dst"))
     build_file_tree(