copier
copier copied to clipboard
`copier update` on dst_path that's **not** the root of the repository doesn't merge gracefully
Whenever I create a copier project not at the repository root level of the, update doesn't work as I would expect (changes I made locally just get overwritten).
Behavior with answers file at root dir (what I expect):
-
copier "gh:my/repo" .
- Add minor change and commit change locally
-
copier update
- Conflict found in changed file, but on overwriting, no change is actually made
Behavior when answers file not at root (what I don't expect):
-
copier "gh:my/repo" project
- Add minor change and commit change locally
-
copier update project
- Conflict found in change, and contents I added are completely overwritten
This is for 6.0.0 and 5.1.0
I'd like to be able to run copier update project
where project
is a directory checked into the repo because I'm trying to use copier to generate projects in a monorepo.
@yajo - I think too at a bare minimum, it would be great for *.rej
files to be generated instead of contents being completely overwritten to be whatever the latest template's contents are!
Also - would this not be fixed any time soon because it's a breaking change?
Sorry for not answering before! I'm having trouble to understand the use case. 🤔
Would you be able to provide some steps that reproduce it on any machine, so I can test it and see the problem?
Thanks!
We have a similar use case. Our application repo should contains out of different copier projects:
application_repo
│── .git
├── temp1 # created via copier path/template1 temp1
│ │── .copier-answers.yml
│ ├── config.conf
│ └── main.py
└── temp2 # created via copier path/template2 temp2
│── .copier-answers.yml
└── main.py
With copier 6.1.0
we are not able to update these templates (temp1
, temp2
).
I tried the following commands to update the template 1:
pqraus@dev:~/application_repo$ copier update /temp1
Updating is only supported in git-tracked subprojects.
pqraus@dev:~/application_repo$ copier -a temp1/.copier-answers.yml update
No git tags found in template; using HEAD as ref
Updating to template version 0.0.0.post6.dev0+ed53ccf
Traceback (most recent call last):
...
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/copier.main.update_diff._fz_mxkf/temp1/.copier-answers.yml'
OK I understand.
A workaround would be:
- Specify a different answers file path when copying.
- Support a templated dir name subfolder in the template itself.
I guess you'd be able to work with 6.1 if you do those 2 things. However indeed this is a valid issue.
I've submitted a PR that should fix this problem, @mhoeger @pQraus. See #1069.