Repository: copier-org/copier
Pull request #1681 (2024-06-28 17:48:26)

fix(tasks): do not consider unsafe if they are being skipped
Fix https://github.com/copier-org/copier/issues/1598

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/copier-org/copier/pull/1681?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 93.50%. Comparing base [(`8f5b627`)](https://app.codecov.io/gh/copier-org/copier/commit/8f5b62775688ab1573c973988cfd4e881f081142?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org) to head [(`57faf0d`)](https://app.codecov.io/gh/copier-org/copier/commit/57faf0d59ad8f6a1b5e7a822daa0601e5fd82af7?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    #1681      +/-   ##
==========================================
- Coverage   97.32%   93.50%   -3.82%     
==========================================
  Files          49       49              
  Lines        5004     5004              
==========================================
- Hits         4870     4679     -191     
- Misses        134      325     +191     
```

| [Flag](https://app.codecov.io/gh/copier-org/copier/pull/1681/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/1681/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org) | `93.50% <100.00%> (-3.82%)` | :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/1681?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).


Patch:
diff --git a/copier/main.py b/copier/main.py
index c862f34..960a41b 100644
--- a/copier/main.py
+++ b/copier/main.py
@@ -241,7 +241,7 @@ class Worker:
         features: set[str] = set()
         if self.template.jinja_extensions:
             features.add("jinja_extensions")
-        if self.template.tasks:
+        if self.template.tasks and not self.skip_tasks:
             features.add("tasks")
         if mode == "update" and self.subproject.template:
             if self.subproject.template.jinja_extensions:


Test patch:
diff --git a/tests/test_tasks.py b/tests/test_tasks.py
index fb00027..05c80b2 100644
--- a/tests/test_tasks.py
+++ b/tests/test_tasks.py
@@ -73,7 +73,6 @@ def test_copy_skip_tasks(template_path: str, tmp_path: Path) -> None:
         quiet=True,
         defaults=True,
         overwrite=True,
-        unsafe=True,
         skip_tasks=True,
     )
     assert not (tmp_path / "hello").exists()