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 @@ -347,7 +347,7 @@ def _execute_tasks(self, tasks: Sequence[Task]) -> None:
347347 operation = _operation .get ()
348348 for i , task in enumerate (tasks ):
349349 extra_context = {f"_{ k } " : v for k , v in task .extra_vars .items ()}
350- extra_context ["_operation " ] = operation
350+ extra_context ["_copier_operation " ] = operation
351351
352352 if not cast_to_bool (self ._render_value (task .condition , extra_context )):
353353 continue
@@ -644,7 +644,7 @@ def match_exclude(self) -> Callable[[Path], bool]:
644644 # Include the current operation in the rendering context.
645645 # Note: This method is a cached property, it needs to be regenerated
646646 # when reusing an instance in different contexts.
647- extra_context = {"_operation " : _operation .get ()}
647+ extra_context = {"_copier_operation " : _operation .get ()}
648648 return self ._path_matcher (
649649 self ._render_string (exclusion , extra_context = extra_context )
650650 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.
966966
967967!!! example
968968
969- Templating `exclude` patterns using `_operation ` allows to have files
969+ Templating `exclude` patterns using `_copier_operation ` allows to have files
970970 that are rendered once during `copy`, but are never updated :
971971
972972 ` ` ` yaml
973973 _exclude:
974- - "{% if _operation == 'update' -%}src/*_example.py{% endif %}"
974+ - "{% if _copier_operation == 'update' -%}src/*_example.py{% endif %}"
975975 ` ` `
976976
977977!!! info
@@ -1587,7 +1587,7 @@ other items not present.
15871587 - ["{{ _copier_python }}", task.py]
15881588 # Run a command during the initial copy operation only, excluding updates
15891589 - command: ["{{ _copier_python }}", task.py]
1590- when: "{{ _operation == 'copy' }}"
1590+ when: "{{ _copier_operation == 'copy' }}"
15911591 # OS-specific task (supported values are "linux", "macos", "windows" and ` None`)
15921592 - command : rm {{ name_of_the_project }}/README.md
15931593 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.
140140
141141Some variables are only available in select contexts :
142142
143- # ## `_operation `
143+ # ## `_copier_operation `
144144
145145The current operation, either `"copy"` or `"update"`.
146146
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ def test_exclude_templating_with_operation(
1414) -> None :
1515 """
1616 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.
1818 """
1919 src , dst = map (tmp_path_factory .mktemp , ("src" , "dst" ))
2020
21- template = "{% if _operation == 'update' %}copy-only{% endif %}"
21+ template = "{% if _copier_operation == 'update' %}copy-only{% endif %}"
2222 with local .cwd (src ):
2323 build_file_tree (
2424 {
@@ -67,8 +67,8 @@ def test_task_templating_with_operation(
6767 "copier.yml" : (
6868 f"""\
6969 _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' }}}}"
7272 """
7373 ),
7474 "{{ _copier_conf.answers_file }}.jinja" : "{{ _copier_answers|to_yaml }}" ,
You can’t perform that action at this time.
0 commit comments