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

dst_path has inconsistent behavior #1842

Open
MigQ2 opened this issue Oct 29, 2024 · 2 comments
Open

dst_path has inconsistent behavior #1842

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

Comments

@MigQ2
Copy link

MigQ2 commented Oct 29, 2024

Describe the problem

I am creating a template where I am trying to use {{ _copier_conf.dst_path | basename }} to get the name of the repository that is rendering the template

When I copy the project intially, it gets correctly rendered as the repo name

However, when I run an update, it gets replaced with something like copier.main.new_copy.nstvyoqn

Is this by design or is this a bug?

I didn't find detailed documentation about dst_path, I see it's used in this example but I don't see it formally documented in the available settings

Expected behavior

I would like {{ _copier_conf.dst_path | basename }} to always be rendered as my destination repo name

Operating system

Linux

Operating system distribution and version

Ubuntu 22.04.3 LTS (running on WSL)

Copier version

9.4.1

Python version

3.10

Installation method

pipx+pypi

@MigQ2 MigQ2 added bug triage Trying to make sure if this is valid or not labels Oct 29, 2024
@sisp
Copy link
Member

sisp commented Nov 4, 2024

It isn't advisable to use the dst_path variable in most cases because its value isn't stable as you noticed and even less so because the path might differ when you moved your local project directory to a different location or another developer cloned the project elsewhere. The example you linked to merely uses the dst_path variable in a message template; that's a different use case.

What's your use case? Does it happen to be related to #1839 and #1617? Are you migrating from Cookiecutter?

@lkubb
Copy link
Contributor

lkubb commented Nov 8, 2024

Note that there is an (undocumented) template variable called _folder_name, which should provide what you are looking for.

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

3 participants