Describe the problem
This is the structure of my template:
├── template
│ ├── {{_copier_conf.answers_file}}.jinja
│ ├── .gitattributes
│ └── {{github_folder}}
│ ├── {% if add_issue_templates %}ISSUE_TEMPLATE{% endif %}
│ │ ├── bug_report.yaml
│ │ ├── config.yml
│ │ └── task.yaml
│ ├── {% if add_PR_template %}pull_request_template.md{% endif %}.jinja
│ ├── {% if target_language == 'python' %}actions{% endif %}
│ │ └── ci-setup-python
│ ├── {% if target_language == 'python' %}generate_bandit_report.py{% endif %}.jinja
│ ├── {% if target_language == 'python' %}generate_coverage_report.py{% endif %}.jinja
│ ├── {% if target_language == 'python' %}generate_ruff_report.py{% endif %}.jinja
│ ├── {% if target_language == 'python' %}sbom{% endif %}
│ │ ├── check_licenses.py
│ │ ├── check_vulnerabilities.py
│ │ ├── manual_licenses.yaml
│ │ └── not_allowed_licenses.yaml
│ ├── .gitattributes
│ └── workflows
│ ├── {% if add_docker_build_and_deploy %}ci-build-and-push-image.yml{% endif %}.jinja
│ ├── {% if add_docker_build_and_deploy %}docker-ci-checklist.md{% endif %}.jinja
│ ├── {% if target_language == 'cpp' %}ci-auto-release-cpp.yml{% endif %}.jinja
│ ├── {% if target_language == 'cpp' %}ci-tagged-release-cpp.yml{% endif %}.jinja
│ ├── {% if target_language == 'cpp' %}ci-tests-cpp.yml{% endif %}.jinja
│ ├── {% if target_language == 'cpp' %}cpp-ci-checklist.md{% endif %}.jinja
│ ├── {% if target_language == 'generic' %}ci-auto-release-generic.yml{% endif %}.jinja
│ ├── {% if target_language == 'generic' %}ci-tagged-release-generic.yml{% endif %}.jinja
│ ├── {% if target_language == 'generic' %}generic-ci-checklist.md{% endif %}.jinja
│ ├── {% if target_language == 'python' %}ci-auto-release-python.yml{% endif %}.jinja
│ ├── {% if target_language == 'python' %}ci-tagged-release-python.yml{% endif %}.jinja
│ ├── {% if target_language == 'python' %}ci-tests-python.yml{% endif %}.jinja
│ ├── {% if target_language == 'python' %}python-ci-checklist.md{% endif %}.jinja
│ ├── {% if target_language == 'python' %}python_coverage_report.yaml{% endif %}.jinja
│ ├── {% if target_language == 'python' %}python_sbom.yml{% endif %}.jinja
│ └── {% if target_language == 'python' %}python_static_analysis.yaml{% endif %}.jinja
This is my copier.yml
# copier.yml
add_issue_templates:
type: bool
help: "Add issue templates?"
default: false
add_PR_template:
type: bool
help: "Add PR template?"
default: false
target_language:
type: str
help: What is the target language?
choices:
- none
- python
- cpp
- generic
add_docker_build_and_deploy:
type: bool
help: "Add docker build and deploy?"
default: false
ci_runner: "***"
github_folder:
type: str
default: ".github"
################################################################################
# gitHub Actions variables
################################################################################
coverage_threshold:
type: int
help: What is the minimum test coverage percentage required in GitHub Actions?
default: 80
poetry_version:
type: str
help: What is the poetry version to use in GitHub Actions?
default: 2.3.2
target_dir:
type: str
help: What is the name of the directory where you want the GitHub actions to run?
validator: >-
{% if not (target_dir.split(" ") | length == 1 ) %}
"target_dir" must be a unique word (no spaces).
{% endif %}
################################################################################
# Copier configuration
################################################################################
_subdirectory: "template"
_min_copier_version: "9.3.1"
_answers_file: .copier-answers.github.yml
_templates_suffix: ".jinja"
_jinja_extensions:
- jinja2_time.TimeExtension
_exclude:
- ".git"
_vcs_ref:
type: str
default: "v1.0.0"
help: "Version of the template to use"
When I run copier copy all the directories and files are created correctly according to my choices. For example, this is my .copier-answers.github.yml:
# Changes here will be overwritten by Copier
_commit: 378719b
_src_path: git@github.com:*****/*****
add_PR_template: true
add_docker_build_and_deploy: true
add_issue_templates: true
ci_runner: ****
coverage_threshold: 80
github_folder: .github
poetry_version: 2.3.2
target_dir: .
target_language: python
And this is the structure created:
.
├── .copier-answers.github.yml
├── .gitattributes
└── .github
├── actions
│ └── ci-setup-python
│ └── action.yml
├── generate_bandit_report.py
├── generate_coverage_report.py
├── generate_ruff_report.py
├── .gitattributes
├── ISSUE_TEMPLATE
│ ├── bug_report.yaml
│ ├── config.yml
│ └── task.yaml
├── pull_request_template.md
├── sbom
│ ├── check_licenses.py
│ ├── check_vulnerabilities.py
│ ├── manual_licenses.yaml
│ └── not_allowed_licenses.yaml
└── workflows
├── ci-auto-release-python.yml
├── ci-build-and-push-image.yml
├── ci-tagged-release-python.yml
├── ci-tests-python.yml
├── docker-ci-checklist.md
├── python-ci-checklist.md
├── python_coverage_report.yaml
├── python_sbom.yml
└── python_static_analysis.yaml
Until this point, everything worked properly. Nevertheless, the problem appears when I want to make some changes with the copier update:
Let's give an example; this is my updated .copier-answers.github.yml:
# Changes here will be overwritten by Copier
_commit: 378719b
_src_path: git@github.com:*****/*****
add_PR_template: true
add_docker_build_and_deploy: true
add_issue_templates: true
ci_runner: ****
coverage_threshold: 80
github_folder: .github
poetry_version: 2.3.2
target_dir: .
target_language: cpp
I only changed the target_language from "python" to "cpp", so the expected result should be that the directories and files with the condition "if target_language == 'python'" should disappear and the ones with the condition "if target_language == 'cpp'" should appear; the remaining files and directories should not suffer any modification. Nevertheless, I don't understand why, but the workflows with the condition "if add_docker_build_and_deploy" also disappear, as well as the directory "ISSUE_TEMPLATE "even though these variables did not change.
This is the structure after the update:
.
├── .copier-answers.github.yml
└── .github
└── workflows
├── ci-auto-release-cpp.yml
├── ci-tagged-release-cpp.yml
├── ci-tests-cpp.yml
└── cpp-ci-checklist.md
Could someone help?
Thank you very much!
Template
This is the structure of my copier template:
├── template
│ ├── {{_copier_conf.answers_file}}.jinja
│ ├── .gitattributes
│ └── {{github_folder}}
│ ├── {% if add_issue_templates %}ISSUE_TEMPLATE{% endif %}
│ │ ├── bug_report.yaml
│ │ ├── config.yml
│ │ └── task.yaml
│ ├── {% if add_PR_template %}pull_request_template.md{% endif %}.jinja
│ ├── {% if target_language == 'python' %}actions{% endif %}
│ │ └── ci-setup-python
│ ├── {% if target_language == 'python' %}generate_bandit_report.py{% endif %}.jinja
│ ├── {% if target_language == 'python' %}generate_coverage_report.py{% endif %}.jinja
│ ├── {% if target_language == 'python' %}generate_ruff_report.py{% endif %}.jinja
│ ├── {% if target_language == 'python' %}sbom{% endif %}
│ │ ├── check_licenses.py
│ │ ├── check_vulnerabilities.py
│ │ ├── manual_licenses.yaml
│ │ └── not_allowed_licenses.yaml
│ ├── .gitattributes
│ └── workflows
│ ├── {% if add_docker_build_and_deploy %}ci-build-and-push-image.yml{% endif %}.jinja
│ ├── {% if add_docker_build_and_deploy %}docker-ci-checklist.md{% endif %}.jinja
│ ├── {% if target_language == 'cpp' %}ci-auto-release-cpp.yml{% endif %}.jinja
│ ├── {% if target_language == 'cpp' %}ci-tagged-release-cpp.yml{% endif %}.jinja
│ ├── {% if target_language == 'cpp' %}ci-tests-cpp.yml{% endif %}.jinja
│ ├── {% if target_language == 'cpp' %}cpp-ci-checklist.md{% endif %}.jinja
│ ├── {% if target_language == 'generic' %}ci-auto-release-generic.yml{% endif %}.jinja
│ ├── {% if target_language == 'generic' %}ci-tagged-release-generic.yml{% endif %}.jinja
│ ├── {% if target_language == 'generic' %}generic-ci-checklist.md{% endif %}.jinja
│ ├── {% if target_language == 'python' %}ci-auto-release-python.yml{% endif %}.jinja
│ ├── {% if target_language == 'python' %}ci-tagged-release-python.yml{% endif %}.jinja
│ ├── {% if target_language == 'python' %}ci-tests-python.yml{% endif %}.jinja
│ ├── {% if target_language == 'python' %}python-ci-checklist.md{% endif %}.jinja
│ ├── {% if target_language == 'python' %}python_coverage_report.yaml{% endif %}.jinja
│ ├── {% if target_language == 'python' %}python_sbom.yml{% endif %}.jinja
│ └── {% if target_language == 'python' %}python_static_analysis.yaml{% endif %}.jinja
To Reproduce
No response
Logs
Expected behavior
Only those files whose conditions are no longer met due to a change in the responses should be updated when I run the copier update.
Screenshots/screencasts/logs
No response
Operating system
Linux
Operating system distribution and version
Ubuntu 24.04
Copier version
copier 9.12.0
Python version
Python 3.12.3
Installation method
pip+pypi
Additional context
No response
Describe the problem
This is the structure of my template:
This is my copier.yml
When I run
copier copyall the directories and files are created correctly according to my choices. For example, this is my .copier-answers.github.yml:And this is the structure created:
Until this point, everything worked properly. Nevertheless, the problem appears when I want to make some changes with the
copier update:Let's give an example; this is my updated .copier-answers.github.yml:
I only changed the target_language from "python" to "cpp", so the expected result should be that the directories and files with the condition "if target_language == 'python'" should disappear and the ones with the condition "if target_language == 'cpp'" should appear; the remaining files and directories should not suffer any modification. Nevertheless, I don't understand why, but the workflows with the condition "if add_docker_build_and_deploy" also disappear, as well as the directory "ISSUE_TEMPLATE "even though these variables did not change.
This is the structure after the update:
Could someone help?
Thank you very much!
Template
This is the structure of my copier template:
To Reproduce
No response
Logs
Expected behavior
Only those files whose conditions are no longer met due to a change in the responses should be updated when I run the
copier update.Screenshots/screencasts/logs
No response
Operating system
Linux
Operating system distribution and version
Ubuntu 24.04
Copier version
copier 9.12.0
Python version
Python 3.12.3
Installation method
pip+pypi
Additional context
No response