When adding the `exclude` option from CLI/API, it extends the definitions found in `copier.yml`.
When adding it in `copier.yml`, it replaces the defaults.
Fixes#215, which explains that it was very unexpected that excluding some extra things included a lot of other things by accident.
It's OK that Copier deletes the destination folder by default when Copier created it. After all, if something failed, you probably don't want that dangling folder around.
However, if the folder existed before (which is always true if you're updating), Copier should not delete it. Yes, this will leave garbage there, but it will be better than removing what is no garbage by accident.
Apart from enforcing this new behavior, a new `--no-cleanup` CLI flag is exposed to `copier copy` to disable this behavior altogether. The flag is not available for `copier update` because it will never work there, as explained above.
This patch fixes#262 and closes#264.
Before this patch, using `!include` was a bit absurd because it would fail under any useful scenario:
- Including with a glob.
- Trying to include more than 1 file.
Now all those are supported, and they can coexist. Besides, the patch is quite simple, which makes it more attractive.
Fix#237.
Instead of being so extra verbose on CI, just add `-ra` to display a summary on non-passing stuff (this lets us know i.e. why a Windows test was skipped).
Add input option on manual triggers of workflows to allow specifying test options if needed.
The new `[tool.poe.tasks]` section and new poetry based workflow are a complete
replacement for the makefile which has also been removed. #129
Also:
- add devtasks for python functions to be referenced as poe tasks
- update CONTRIBUTING.MD #154 to keep things coherent
- remove reference to tox
- update ci to work with more expressive toml syntax (upgrade pip)
- and use poe tasks in ci
1. Run when a release is published, not created. You might create it as draft and, then, after publishing, it wouldn't get run.
2. Install from pip after restoring cache, not before. To install faster.
Scenario:
1. Your project is in version `v1`.
2. You update ito `v2a1` using `--prerelease`.
3. Later, you just update without passing `--prerelease`.
Current result: Copier will try to downgrade your project to the latest normal release. Migrations do not work backwards, so this will leave your project broken.
Expected result: Copier forbids downgrading.
@Tecnativa TT23705
Before this patch, Copier didn't ignore prereleases when detecting latest template tag.
This is mostly a bug because there's no way to safely upgrade a template to the latest non-prerelease tag automatically.
This a behavioral change that probably didn't hit anybody out there, but enough to make a new big release.
- Add `only_diff` docs.
- Link CLI docs with those from configuration.
- Add link on `copier --help` to the docs.
- Include `copier --help-all` in the online docs.
Mkdocs uses `python-markdown`, and [they say](https://python-markdown.github.io/#differences):
> The syntax rules clearly state that when a list item consists of multiple paragraphs, “each subsequent paragraph in a list item must be indented by either 4 spaces or one tab” (emphasis added). However, many implementations do not enforce this rule and allow less than 4 spaces of indentation. The implementers of Python-Markdown consider it a bug to not enforce this rule.
As we were using 2 spaces for markdown files (which looks better in source code), some indented lists were not displaying properly in the docs page.
Thus I change the setting to 4 spaces. Prettier will now enforce them, and mkdocs will display things properly.
- Prepare for a new release.
- Add configuring page, with more explicit docs and examples for each option.
- Remove configuration stuff from creation page.
- Comparisons are ugly, so remove them from the index page.
Pip, poetry and pre-commit defaulted to OS-specific cache and venv dirs. This made the caching system less useful on macOS and Windows.
Now, all is stored under $PWD/.venv and cached from there. This works fine across different OS. Also, the OS is added to the cache key.
- Ignore errors when executing `shutil.rmtree()`, because it seems like it's common to fail when deleting git repos on Windows, and since these are temp files, we don't really care that much there's garbage left. Any good OS should clean the temp folders automatically.
- Always find Jinja templates in `PosixPath` mode.
- Ignore `OSError` when trying to enter a possibly git root directory. This is yielded by Windows when the path is a URL and we don't really care about it.
- Fix some tests with non-windows hardcoded stuff.
- Fix a test that was using a Bash script. Modified to be Python, which should work fine cross-system.
- Remove external python dependencies (yaml, plumbum) from test task/migration files. These are available on Linux because it gets the python env from the venv, but on Windows, it uses the main python interpreter and breaks. After all, that's not very important here.
- Do not modify EOL in CI.
- Use python executable in tests instead of python3.
- Update pre-commit versions to include https://github.com/pre-commit/pre-commit-hooks/pull/509.
- Disable autorebasing.
- Disable pre-commit on CI on Windows.
- Require python 3.8 on Windows, where `tempfile` supports autoremoving directories with read-only files.
Let's see if tests work under windows or mac.
Don't fail fast the tests
If there's one Python version or OS that fails, I still want to see results for the other matrix runs.
It seems that the proper command was `git diff-tree` and not `git diff`, which was accidentally working until today, where some things got fixed on Git 2.28 and GH actions updated their images to use that version of Git and broke everything for us.
Before this patch, a templated default was counting as init data because it was different from the original default after rendereing, making copier believe the user provided an answer.
This patch fixes#230 by avoiding to parse questions that have no init data answer in the step of filling `data_from_init`. Those defaults will be used later as `data_from_asking_user` if needed.
#221 introduced a regression that made the user prompt always display the default value from `copier.yml` file instead of the last answer from `.copier-answers.yml` when the latter one was available.
Here I fix that and test it too. Added a new dev dependency (pytest-timeout) to use it in tests that expect responses from STDIN and for some reason fail to obtain them do not hang in and endless loop.
I also removed the `conftest.py` file, which was only declaring a fixture that is no longer used and can actually be fixed easily using https://stackoverflow.com/a/51893526/1468388.
@Tecnativa TT23705
When migrating a template, it can happen that the answers spec is modified.
When that happens, the migration script should modify the answers file. Thus, the update process should reload answers after running pre-migrations.
That's what it is doing now with this patch.
@Tecnativa TT23705
- `ConfigData` objects now know where do answers come from.
- Their `.data` attribute is now a computed property that merges all those answer sources in priority order.
- To merge dicts, `ChainMap` is used extensively.
- `query_user_data` gets both `last_answer_data` and `forced_answers_data` instead of the single `answers_data` argument it got before.
- By knowing where does an answer come from, now Copier avoids asking something if the user already answered that from other source. For example, if you use `copier -d some_question=some_answer copy $src $dst`, then Copier will not ask you about `some_question` again, because you already answered that. 🎉
- All answer sources are deep-copied to avoid modifying mutable dicts and affecting further copier executions.
- A minimal amount of tests got updated as they were now supposed to fail with new behavior.
- Ignore flake8 `E501 line too long` errors. We use black, that's just unnecessarily annoying.
@Tecnativa TT23705