-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Inconsistent update
behavior when a generated file was deleted
#1721
Comments
In case 2, if Copier would just leave the file absent, you'd never know it changed upstream. A better solution would be a merge conflict indeed, but you're not expected to trust updates blindly. You should review them before commiting, because obviously there can be conflicts. If you want to automate the updates, then do ˋcopier update --exclude the/path/i/dont/care/in/template.txtˋ and it will work as you expect. |
First, thanks a lot for taking the time to look into my issues/proposal (and for maintaining Copier)!
I can see arguments for either. For (a): I deleted the file intentionally and thereby declared I'm not interested in the file, neither in updates to it. For the usual template, I wouldn't expect any interdependencies between separate files (at least not between those that projects would delete intentionally). If the deletion breaks something down the line or I change my mind, I can recover the necessary files by just running For (b):
Of course. In contrast to the
Yes, this is a substantial motivation here - there are currently around 36 projects generated from the mentioned template (soon likely several times that), which all need to be kept up to date (using Renovate, similar to Dependabot). Renovate does not allow specifying Copier CLI arguments though (I wrote the feature PR initially with support for that, in part because of the Something that would help alleviate the immediate automation problems is if Copier respected |
I wouldn't like to make updates interactive again. Life is better since we turned off that.
After a 2nd thought, this is probably the right solution. Thank you! |
Agreed. I'm not sure which part of my proposal indicated making updates interactive though. :)
👍 Since you closed #1718 as not planned, should files listed in |
Sorry I've had like 4 different requests about the same subject at the same time and it's been confusing to me. Let's keep the case for "skip if exists" out of the picture for now. It's probably unrelated. You were trying to use that feature for what it isn't meant, so the behavior was surprising. Once we fix this, you will probably don't need to care about skip if exists. And if you do, then the issue will probably be more clear. |
Describe the problem
Having deleted a file in a generated project,
copier update
behaves depending on the template's evolution:(re)copy
operation was requested.Template
https://github.com/salt-extensions/salt-extension-copier (sadly requires --trust, but this could be reproduced easily with a simple demo template)
To Reproduce
copier copy --trust --defaults --data project_name=foo --data author='Foo Bar' --data author_email='[email protected]' --data ssh_fixtures=true --vcs-ref=0.3.4 https://github.com/salt-extensions/salt-extension-copier foo
cd foo; git init && git add . && git commit -m "initial commit"
rm tests/conftest.py setup.py && git commit -am rm
copier update --trust --skip-answered
git status
[shows new, untrackedtests/conftest.py
, but notsetup.py
]Logs
No response
Expected behavior
(2) is surprising imho. I would expect one of the following behaviors:
a) Don't regenerate the file.
b) Warn about a merge conflict.
(a) makes the most sense to me here. It was intentionally deleted and we're running
update
, notrecopy
.Screenshots/screencasts/logs
No response
Operating system
macOS
Operating system distribution and version
14.6
Copier version
9.1.0
Python version
CPython 3.11
Installation method
pipx+pypi
Additional context
This came up during the discussion of #1718.
The difference between this issue and the mentioned one is that paths affected by
skip_if_exists
are always recreated onupdate
, regardless of the template's evolution.The text was updated successfully, but these errors were encountered: