- 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 commit fixes#119. Summary:
- Depend on packaging to get a good implementation of PEP 440.
- Document new behaviors.
- Add support for migrations.
- Checkout by default the most modern git tag available in the template.
- Reuse `run_tasks` to run migrations too.
- Use `git describe --tags --always` to obtain template commit, to get a version parseable by PEP 440.
- Update `test_updatediff` to with new behaviors.
@Tecnativa TT20357
Fix#88 the easiest way possible. Changes summary:
- A new `--vcs-ref` flag that indicates which commit/ref you want to copy, and only applies when the source directory is git-versioned.
- A new `--no-diff` flag to `copier update` skips the smartypants diff behavior.
What it does?
- Checks you are updating a git-versioned destination from a git-versioned source.
- Clones the destination into temp dir.
- Does a `copier copy -f tmp_src tmp_dst` (yes, a temp dir also).
- Gets the git diff between `tmp_dst` and `dst_path`.
- Performs a normal `copier update dst_path`.
- Applies the git diff at the end, to try to respect downstream project evolution.
@Tecnativa TT20357