- Help messages were too separated from question and too close to previous question due to weird newlines.
- Secrets had no indication that they were secrets. Now they have a 🕵️ icon.
When data came from `--data` flag, it was always a string.
If some data was expected to be of another type, it could make the template fail.
The type casting system must be applied also to user answers, so here's the patch, docs and tests.
@Tecnativa TT20357
Close#175 by supporting old git versions. These will provide a worse update experience, but still work. Instead of failing, a warning is printed for the user.
- Do not produce contextless diff (`--unified=0`), as it leads to weird results sometimes. `.rej` files provide a saner output. Actually https://git-scm.com/docs/git-apply#Documentation/git-apply.txt---unidiff-zero recommends not using contextless patches.
- Ask `git diff` to *never* join 2 code hunks, even if they are only separated by 1 line (`--inter-hunk-context=-1`). This gives Copier most chances to reduce the amount of rejected hunks.
- When a template is to be reformatted by a pre-commit hook after copy, make sure git hooks are respected, so the updated diff matches reality more closely.
- Add and use a new helper to comfortably build a file tree from a test, to provide a way to avoid having dangling sample trees and git samples.
@Tecnativa TT20357
When somebody calls `copier update` to reapply a template, respecting subproject evolution, but just to apply some changes to some answers, the updatediff system reverted those changes.
Now they are respected, so if calling `copier update` with new data, that new data will be applied to the subproject.
The basic fix is that when creating the temporary copy in the old commit (the one used to compare), it is created using last answers obtained from the subproject, excluding any new answers passed by the user.
#169 improved the situation but certainly it didn't fix it completely. This hardened test proves it works better now.
There was a bug in how update diff was computed. As you can see, the temporary copy that was made to produce that diff didn't get the same answers as the current project. Thus, every time the user answered something different, a diff was generated and a `.rej` file was created.
Just try this and you'll see:
```bash
copier -f update
git add .
git commit -m updated
copier -f update
git status
```
The 2nd time you update, all files should be identical and untouched. However, that wasn't the case.
I took the chance to update this test's fixture from `dst` to `tmpdir`, which is more standard and comfortable to debug.
@Tecnativa TT20357
This is a switch attribute, not a flag.
Without this patch, using this feature yields this error:
```
➤ copier -fa .altered-copier-answers.yml update
Traceback (most recent call last):
File "/home/yajo/.local/bin/copier", line 8, in <module>
sys.exit(CopierApp.run())
File "/home/yajo/.local/pipx/venvs/copier/lib64/python3.7/site-packages/plumbum/cli/application.py", line 577, in run
inst, retcode = subapp.run(argv, exit=False)
File "/home/yajo/.local/pipx/venvs/copier/lib64/python3.7/site-packages/plumbum/cli/application.py", line 572, in run
retcode = inst.main(*tailargs)
File "/home/yajo/.local/pipx/venvs/copier/lib64/python3.7/site-packages/copier/cli.py", line 17, in _wrapper
return method(*args, **kwargs)
File "/home/yajo/.local/pipx/venvs/copier/lib64/python3.7/site-packages/copier/cli.py", line 172, in main
dst_path=destination_path, only_diff=self.only_diff,
File "/home/yajo/.local/pipx/venvs/copier/lib64/python3.7/site-packages/copier/cli.py", line 111, in _copy
**kwargs,
File "/home/yajo/.local/pipx/venvs/copier/lib64/python3.7/site-packages/copier/main.py", line 123, in copy
conf = make_config(**locals())
File "/home/yajo/.local/pipx/venvs/copier/lib64/python3.7/site-packages/copier/config/factory.py", line 59, in make_config
answers_data.update(load_answersfile_data(dst_path, answers_file))
File "/home/yajo/.local/pipx/venvs/copier/lib64/python3.7/site-packages/copier/config/user_data.py", line 90, in load_answersfile_data
with open(Path(dst_path) / (answers_file or ".copier-answers.yml")) as fd:
File "/usr/lib64/python3.7/pathlib.py", line 920, in __truediv__
return self._make_child((key,))
File "/usr/lib64/python3.7/pathlib.py", line 699, in _make_child
drv, root, parts = self._parse_args(args)
File "/usr/lib64/python3.7/pathlib.py", line 653, in _parse_args
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not bool
```
@Tecnativa TT20357
This is a regression from #162 where `__version__` was removed due to conflicts with how black and poetry-dynamic-versioning work.
Now those conflicts are fixed and `copier --version` works again. This was what it was returning before:
```bash
➤ copier --version
copier (version not set)
```
BEWARE: In a development, it will always return `0.0.0`, but this is expected because poetry-dynamic-versioning autopatches this on release.
In `.pre-commit-config.yaml`, `require_serial: true` is added to all local tasks that run under `poetry run`. This is because when entering `poetry run`, poetry-dynamic-versioning does its magic and patches the versions in `pyproject.toml` and `__init__.py`, and unpatches them when ending the execution. If running in parallel (default pre-commit behavior), some patches are reverted and some aren't, producing random failed lints.
@Tecnativa TT20357
After #163, a `copier.yml` file without a `_answers_file` definition would default to `None` instead of `".copier-answers.yml"` as expected.
I modified some tests to reproduce this failure, and fixed them.
@Tecnativa TT20357
With this enhacenment, template designers are able to choose a different default path for the `.copier-answers.yml` file, and users are still able to alter it via their API/CLI calls.
The main purpose for this is to let users use several templates to fill the same destination directory, and still be able to autoupdate all of them by just providing the answers file path to use.
@Tecnativa TT20357
It is not needed if we consider all unknown dependencies as third party by default. This will save an apparently unneeded diff and many possible git conflicts in the future.