File tree Expand file tree Collapse file tree 4 files changed +10
-10
lines changed Expand file tree Collapse file tree 4 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -362,7 +362,7 @@ def _execute_tasks(self, tasks: Sequence[Task]) -> None:
362
362
operation = _operation .get ()
363
363
for i , task in enumerate (tasks ):
364
364
extra_context = {f"_{ k } " : v for k , v in task .extra_vars .items ()}
365
- extra_context ["_operation " ] = operation
365
+ extra_context ["_copier_operation " ] = operation
366
366
367
367
if not cast_to_bool (self ._render_value (task .condition , extra_context )):
368
368
continue
@@ -663,7 +663,7 @@ def match_exclude(self) -> Callable[[Path], bool]:
663
663
# Include the current operation in the rendering context.
664
664
# Note: This method is a cached property, it needs to be regenerated
665
665
# when reusing an instance in different contexts.
666
- extra_context = {"_operation " : _operation .get ()}
666
+ extra_context = {"_copier_operation " : _operation .get ()}
667
667
return self ._path_matcher (
668
668
self ._render_string (exclusion , extra_context = extra_context )
669
669
for exclusion in self .all_exclusions
Original file line number Diff line number Diff line change @@ -966,12 +966,12 @@ Each pattern can be templated using Jinja.
966
966
967
967
!!! example
968
968
969
- Templating `exclude` patterns using `_operation ` allows to have files
969
+ Templating `exclude` patterns using `_copier_operation ` allows to have files
970
970
that are rendered once during `copy`, but are never updated :
971
971
972
972
` ` ` yaml
973
973
_exclude:
974
- - "{% if _operation == 'update' -%}src/*_example.py{% endif %}"
974
+ - "{% if _copier_operation == 'update' -%}src/*_example.py{% endif %}"
975
975
` ` `
976
976
977
977
!!! info
@@ -1587,7 +1587,7 @@ other items not present.
1587
1587
- ["{{ _copier_python }}", task.py]
1588
1588
# Run a command during the initial copy operation only, excluding updates
1589
1589
- command: ["{{ _copier_python }}", task.py]
1590
- when: "{{ _operation == 'copy' }}"
1590
+ when: "{{ _copier_operation == 'copy' }}"
1591
1591
# OS-specific task (supported values are "linux", "macos", "windows" and ` None`)
1592
1592
- command : rm {{ name_of_the_project }}/README.md
1593
1593
when : " {{ _copier_conf.os in ['linux', 'macos'] }}"
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ The name of the project root directory.
140
140
141
141
Some variables are only available in select contexts :
142
142
143
- # ## `_operation `
143
+ # ## `_copier_operation `
144
144
145
145
The current operation, either `"copy"` or `"update"`.
146
146
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ def test_exclude_templating_with_operation(
14
14
) -> None :
15
15
"""
16
16
Ensure it's possible to create one-off boilerplate files that are not
17
- managed during updates via `_exclude` using the `_operation ` context variable.
17
+ managed during updates via `_exclude` using the `_copier_operation ` context variable.
18
18
"""
19
19
src , dst = map (tmp_path_factory .mktemp , ("src" , "dst" ))
20
20
21
- template = "{% if _operation == 'update' %}copy-only{% endif %}"
21
+ template = "{% if _copier_operation == 'update' %}copy-only{% endif %}"
22
22
with local .cwd (src ):
23
23
build_file_tree (
24
24
{
@@ -67,8 +67,8 @@ def test_task_templating_with_operation(
67
67
"copier.yml" : (
68
68
f"""\
69
69
_tasks:
70
- - command: echo {{{{ _operation }}}} >> { json .dumps (str (task_counter ))}
71
- when: "{{{{ _operation == 'copy' }}}}"
70
+ - command: echo {{{{ _copier_operation }}}} >> { json .dumps (str (task_counter ))}
71
+ when: "{{{{ _copier_operation == 'copy' }}}}"
72
72
"""
73
73
),
74
74
"{{ _copier_conf.answers_file }}.jinja" : "{{ _copier_answers|to_yaml }}" ,
You can’t perform that action at this time.
0 commit comments