-
-
Notifications
You must be signed in to change notification settings - Fork 233
fix: updates with floating tags #2354
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
base: master
Are you sure you want to change the base?
Conversation
e928668 to
f7dfa1a
Compare
|
Thanks for submitting this PR, @maganaluis! 🙇 A conceptual question before diving into code details: One of the arguments you're documenting is traceability and reproducibility because the SHA is an immutable and unique reference of the template version while a symbolic reference can be mutated. I wonder whether we'd even want both instead of either one or the other. Wouldn't a user of a template with regular SemVer tags also benefit from the additional immutable reference information? For example, we could introduce a new metadata field in the answers file: _commit: v1.2.3
+_commit_sha: e3b0c44298fc1c149afbf4c8996fb92427ae41e4
_src_path: ...
...And in your case, you'd also know which floating tag is used to identify updates. In case you use a non-SemVer floating tag like WDYT? /cc @pawamoy |
|
Just to make sure I understand: we still need the semver tag to know whether we're upgrading or downgrading when we do an update, right? What happens when the floating tag is v1, and you update to v1? Copier will not only have to compare both versions, but also checkout the template to compare commit SHAs. Then does it know if it's an upgrade or a downgrade? Does it use the commit date to know that? |
|
I think the scenarios are like this:
|
|
Thanks! Then yeah I don't see any downsides to recording the commit SHA and using it when we can't parse the version or when there's no new version (except maybe a longer execution time when a project is updated and there's indeed no new version? but that's not very impactful) 👍 |
|
This is a reasonable ask, I think I would still leave the setting
|
|
Sounds good. Just some additional ideas for the flag name:
|
|
I think this is at a good place now for a second revision. |
Problem
Copier stores git refs (tags/branches) in
_commitfield of.copier-answers.yml. When using moving/floating tags (e.g.,workflows/v1,stable/v2,latest), futurecopier updatecommands fail because the tag now points to a different commit.Revision 1
Solution
Added
--resolve-commit-to-shaflag that stores immutable SHA hashes instead of git refs.Implementation:
--resolve-commit-to-sha_resolve_commit_to_sha: trueincopier.ymlUsage:
Changes:
copier/_main.py: Addedresolve_commit_to_shafield to Worker class and logic in_answers_to_remember()copier/_cli.py: Added CLI flagcopier/_template.py: Added template config supporttests/test_resolve_commit_to_sha.py: Coverage for new functionalityFixes #987
Revision 2
Solution: Copier now stores BOTH semantic version and SHA hash, then automatically
chooses which to use during updates.
Key Changes:
Dual-Versioning - Always stores both values:
_commit: Semantic version (human-readable)_commit_sha: SHA hash (machine-reliable)Automatic Tag Resolution - Detects and handles floating tags:
latest,stable/*,main,master,develop,feat/*,etc.
Renamed Flag:
--resolve-commit-to-sha→--ignore-git-tagsUsage:
Implementation:
Modified Files:
copier/_main.py: Automatic tag resolution logic, dual-versioning storage (~40 linesreduced)
copier/_subproject.py: Use SHA for FROM version in diffscopier/_cli.py: Renamed flagcopier/_template.py: Config properties forignore_git_tagsandstable_tag_patternstests/test_ignore_git_tags.py: Complete rewrite with end-to-end floating tag testsResolution Logic: