Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem updating a project created from a recursive template #1839

Closed
hribera opened this issue Oct 29, 2024 · 2 comments
Closed

Problem updating a project created from a recursive template #1839

hribera opened this issue Oct 29, 2024 · 2 comments
Labels
bug triage Trying to make sure if this is valid or not

Comments

@hribera
Copy link

hribera commented Oct 29, 2024

Describe the problem

We have a copier template that has the following structure (simplified):

copier-template/
├── project
│   └── {{ repo_name }}
│       ├── {{ _copier_conf.answers_file }}
│       ├── Dockerfile
│       ├── LICENSE
│       ├── Makefile
│       ├── pyproject.toml
│       ├── tests
│       └── README.md
├── copier.yml
├── pyproject.toml
├── README.md
└── tests

The copier.yml file is:

# CONFIGURATION -------------------------
_subdirectory: project
_templates_suffix: ""
_jinja_extensions: []

# PROMPT --------------------------------
repo_name:
[and so on...]

We created a project using this template named copier-project.

Then we updated the template to have another file named CONTRIBUTING.md inside the {{ repo_name }} folder, and updated the version of the template with its corresponding tag and all.

We then wanted to update the project copier-project created using this template. So within the folder copier-project we ran:

poetry run copier update --skip-tasks --skip-answered --trust --vcs-ref=HEAD .

Which updated the project with the message Updating to template version 0.2.7 and no errors.

However, we saw that the update command had created a new folder within copier-project named copier-project and had added the CONTRIBUTING.md file within this new folder, which completely breaks the structure of the project:

copier-project/
├── .copier-answers.yml
├── Dockerfile
├── LICENSE
├── Makefile
├── pyproject.toml
├── tests
├── README.md
└── copier-project
    └── CONTRIBUTING.md

Template

The template used is a private template and cannot be shared.

To Reproduce

No response

Logs

No response

Expected behavior

We would have expected that the CONTRIBUTING.md file to be added in the copier-project folder.

Screenshots/screencasts/logs

No response

Operating system

Linux

Operating system distribution and version

20.04

Copier version

9.4.1

Python version

3.11

Installation method

pip+pypi

Additional context

I have found that in here it specifies that for recursive templates one should use the _subdirectory option in configuration. However, we weren't able to add the {{ repo_folder }} as a _subdirectory directly, so we added the project folder to get around the problem. We do need to have tests for the template, have a separate pyproject.toml for the template, among other things, so that is why we can't use the root directly either.

@hribera hribera added bug triage Trying to make sure if this is valid or not labels Oct 29, 2024
@pawamoy
Copy link
Contributor

pawamoy commented Oct 29, 2024

Hi @hribera, thanks for the report.

I believe that's the same issue as #1617, and I would therefore characterize it as "misuse". Can you check #1617 and tell us if that helps you solve your problem?

@hribera
Copy link
Author

hribera commented Oct 30, 2024

Hi @pawamoy,

Yes it is the same issue. Noted that it is considered a misuse, and so we will drop the {{ repo_name }} folder as advised in #1617.

Thanks for your quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Trying to make sure if this is valid or not
Projects
None yet
Development

No branches or pull requests

2 participants