-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 🐛 fix copier update #144
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
Conversation
| - name: Pull request with updates from template | ||
| run: | | ||
| just update-from-template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this to use the just recipe
| update-from-template: | ||
| uvx copier update --trust --defaults | ||
| # Do not update existing source files | ||
| uvx copier update --trust --defaults $(find src/{{ github_repo_snake_case }} -type f -printf "--exclude %p ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem was that running copier update ... deleted some files in the src/{{ github_repo_snake_case }} folder. Maybe because the folder name is templated?
In any case, there is a _skip_if_exists property in copier.yml, where you can set which files not to touch if they exist. Setting this worked for some test files I put in the folder, but interestingly not for __init__.py and py.typed. Even skipping all files in the folder didn't catch these two 🤔 .
The _exclude property is similar, but it stays in force regardless of the file existing, so a deleted file will not be recreated.
This version with the --exclude flag is a workaround: it excludes all files in the folder that exist, recreating the behaviour of _skip_if_exists in copier.yml. We could narrow it to only the two problematic files if this is too broad.
Any other ideas welcome!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Yea, I had been wondering about this.. We'll have to see how we use all of this stuff in practice, will be interesting!
| @@ -1,2 +1,2 @@ | |||
| # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY | |||
| {{ dict(_copier_answers, copyright_year=copyright_year) | to_nice_yaml -}} | |||
| {{ dict(_copier_answers, github_repo=github_repo, copyright_year=copyright_year) | to_nice_yaml -}} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise copier will use a temp folder name it uses under the hood
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change and how it relates to this PR. What is this doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github_repo defaults to the folder name. When updating, copier seems to keep the project in a temporary folder when it resolves the variables and ends up setting the name of this folder as github_repo. If we save the correct github_repo in the answers file, it will be read from there instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @@ -1,2 +1,2 @@ | |||
| # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY | |||
| {{ dict(_copier_answers, copyright_year=copyright_year) | to_nice_yaml -}} | |||
| {{ dict(_copier_answers, github_repo=github_repo, copyright_year=copyright_year) | to_nice_yaml -}} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change and how it relates to this PR. What is this doing?
| update-from-template: | ||
| uvx copier update --trust --defaults | ||
| # Do not update existing source files | ||
| uvx copier update --trust --defaults $(find src/{{ github_repo_snake_case }} -type f -printf "--exclude %p ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Yea, I had been wondering about this.. We'll have to see how we use all of this stuff in practice, will be interesting!
Description
This PR fixes and improves copier update.
Closes #143
This PR needs a medium-depth review.
Checklist
just run-all-- will fail until some other PRs are merged in