Replies: 1 comment 1 reply
-
El mar., 19 jul. 2022 9:13, pQraus ***@***.***> escribió:
How to add new features / fix bugs in the template repository? Do you have
a workflow for this?
Let's say you want to add a new feature in your template. Because the
config in the template repo is only a template you can't really test the
scripts ... You will need an actual project to do this.
All you have to do is to add unit tests to your template. In those tests,
render the project to a temporary directory and make your assertions.
Check out this project where I was a maintainer some time ago. In the tests
folder, you can see it uses pytest to test all relevant template features:
https://github.com/Tecnativa/doodba-copier-template/tree/a73f1109277659121502d740c9039c09d1e7a9aa/tests
This way, you can do TDD in the template directly.
- When everything is fine only the .copier-answers.yml should be
changed. But actually there is also a .rej file. For the explained
example it is the main.py.rej:
diff a/main.py b/main.py (rejected hunks)
@@ -2,2 +2,3 @@ with open("config.conf", "r") as file:
config = file.read()
- print(config)
\ No newline at end of file
+ print(config)
+print("Script finished")
\ No newline at end of file
Why does this file exist? What is the purpose? Does it is a bug? We expect
that there is only the change in the answers-file because the main.py in
this project is already updated.
That file is created by copier when it finds a conflict that it cannot
solve automatically during an update. Check out the docs:
https://copier.readthedocs.io/en/stable/updating/
In your case, it might be related to those files with `No newline at end of
file`. When you add one line to a file like that, you're in reality
changing 2 lines: the 1st one gets changed with a newline at the end, and
the 2nd one is added. This produces more diff than you expect, and it's
sometimes the source of unexpected conflicts.
This is a classic problem. Advanced code editors allow to configure
automatic addition of newline at the end always. That way, adding a line at
the bottom actually produces a diff of 1 line.
… |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pQraus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
Actually, we are very happy with the options which copier provide us for templating. But I have question and maybe it is a bug.
How to add new features / fix bugs in the template repository? Do you have a workflow for this?
Let's say you want to add a new feature in your template. Because the config in the template repo is only a template you can't really test the scripts ... You will need an actual project to do this.
Let me explain our current workflow:
main.py
) read the rendered config file:copier template_repo .
)main.py
(because the python script uses the config file it can be only executed/tested in the project). After this our python script looks like this:git format-patch master..feature-branch
(in project repo)git am path/to/patch/file(s)
Now the new feature is in our template.
copier update
in the project repo..copier-answers.yml
should be changed. But actually there is also a.rej
file. For the explained example it is themain.py.rej
:Why does this file exist? What is the purpose? Does it is a bug? We expect that there is only the change in the answers-file because the
main.py
in this project is already updated.Is there another workflow?
How can we disable the creation of the
.rej
file?Beta Was this translation helpful? Give feedback.
All reactions