-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Overwrite does not apply -> let's just overwrite always #741
Comments
Also - I'm more than happy to submit a PR if it's determined this is not the intended behavior. Just looking to brainstorm and verify I'm not missing anything here, as well as determine a path forward. |
Hi! Thanks for the report and sorry for taking so long to answer. Following your steps I managed to reproduce the problem. First of all, we have to keep in mind Copier is behaving "correctly". I mean that it is supposed to respect your changes in The smart update process is "smart" because it will only update something if it has changed in the template. Otherwise, Copier understands that you changed that file in your project because you had to, and live happy with that. So, if your expectations are that Copier should put
However, there's a real bug: Copier shouldn't ask you to overwrite something that it's not going to overwrite. The problem comes from a design dated before the smart update system was introduced in Copier 3. This fix is to drop this "overwrite file?" form, as explained in #343 (comment). Basically asking the user is useless in updates, because of 2 reasons:
Also it's useless in copies because you're supposed to be copying something for the 1st time, so you should want everything overwritten. So copier should overwrite always, period. The tasks to do would be something around this:
That'd be great! But let me advice you this is not easy task, as this feature is used very often. Do you still want to do it? |
@yajo What's the status of this as I've the same problem for OCA repos? |
For now, nothing changed apart from what I already explained in #741 (comment). The important part is that Copier is behaving correctly. It's just a UX problem, and the plan is to remove the overwrite question and just overwrite always. After all, updates are only allowed in git-tracked projects, and you can always review the diff afterwards with git, which is more comfortable and powerful than anything else I could possibly do. As a workaround, you can pass |
Updates not only overwrite files when actually updating, but also when applying the git diff. Since only git-tracked subprojects can be updated, in reality there's no problem when overwriting. I find myself always overwriting and later fixing stuff with git tools. BREAKING CHANGE: Updates will overwrite existing files always. If you need to select only some files, just use `git mergetool` or `git difftool` after updating. BREAKING CHANGE: Flag `--overwrite/-w` disappeared from `copier update`. It is now implicit. BREAKING CHANGE: Flag `--force/-f` disappeared from `copier update`. The equivalent is now `copier update -l`. Fix #741.
Updates not only overwrite files when actually updating, but also when applying the git diff. Since only git-tracked subprojects can be updated, in reality there's no problem when overwriting. I find myself always overwriting and later fixing stuff with git tools. BREAKING CHANGE: Updates will overwrite existing files always. If you need to select only some files, just use `git mergetool` or `git difftool` after updating. BREAKING CHANGE: Flag `--overwrite/-w` disappeared from `copier update`. It is now implicit. BREAKING CHANGE: Flag `--force/-f` disappeared. The equivalents are now `copier [copy,recopy] -wl` or `copier update -l`. Fix #741.
Updates not only overwrite files when actually updating, but also when applying the git diff. Since only git-tracked subprojects can be updated, in reality there's no problem when overwriting. I find myself always overwriting and later fixing stuff with git tools. BREAKING CHANGE: Updates will overwrite existing files always. If you need to select only some files, just use `git mergetool` or `git difftool` after updating. BREAKING CHANGE: Flag `--overwrite/-w` disappeared from `copier update`. It is now implicit. BREAKING CHANGE: To update via API, `overwrite=True` is now required. Fix #741.
Updates not only overwrite files when actually updating, but also when applying the git diff. Since only git-tracked subprojects can be updated, in reality there's no problem when overwriting. I find myself always overwriting and later fixing stuff with git tools. BREAKING CHANGE: Updates will overwrite existing files always. If you need to select only some files, just use `git mergetool` or `git difftool` after updating. BREAKING CHANGE: Flag `--overwrite/-w` disappeared from `copier update`. It is now implicit. BREAKING CHANGE: To update via API, `overwrite=True` is now required. Fix #741.
Describe the problem
When performing a
copier update
on a fresh repository, copier prompts to overwrite files, but doesn't actually overwrite them.Template
https://github.com/andrew-glenn/example-copier-template
To Reproduce
Expected behavior
Copier overwrites the file it prompts me for.
Environment
copier 6.1.0
Python 3.9.10
Additional context
I wrapped
git
to log the command it was performing. The following logs correspond to this code-block. I've truncated the path of the tempfiles for readability.Code:
copier/copier/main.py
Lines 697 to 708 in 141ddf1
Logs:
Running the
git diff
at the end shows thatHEAD
is the upstream template, andFETCH_HEAD
is the local project.In the case of an overwrite, I believe the order should be reversed, so that
HEAD
overwritesFETCH_HEAD
, not maintaining the status-quo, and negating the affirmation to overwrite the file from upstream template.Am I missing something?
The text was updated successfully, but these errors were encountered: