Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: 🐛 fix copier update #144

wants to merge 1 commit into from

Conversation

martonvago
Copy link
Contributor

Description

This PR fixes and improves copier update.

Closes #143

This PR needs a medium-depth review.

Checklist

  • Added or updated tests
  • Updated documentation
  • Ran just run-all -- will fail until some other PRs are merged in

@martonvago martonvago self-assigned this Aug 15, 2025
@martonvago martonvago moved this from Todo to In Review in Iteration planning Aug 15, 2025

- name: Pull request with updates from template
run: |
just update-from-template
Copy link
Contributor Author

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

@@ -115,7 +115,8 @@ build-contributors:

# Check for and apply updates from the template
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 ")
Copy link
Contributor Author

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!!

@@ -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 -}}
Copy link
Contributor Author

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

@martonvago martonvago marked this pull request as ready for review August 15, 2025 13:03
@martonvago martonvago requested a review from a team as a code owner August 15, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Refine update-from-template workflow
1 participant