1797 Commits

Author SHA1 Message Date
Jairo Llopis
b479cb9804 Make exclude extend if called from CLI/API
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.
2020-09-18 10:55:09 +00:00
Jairo Llopis
57d138caea Copier will only cleanup the folder if it created it
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.
2020-09-17 20:10:31 +00:00
Jairo Llopis
aa1bfa1ded Fix broken docs links
Fixes some bugs introduced in #271 by mistake. That automerge bot was too fast.
2020-09-17 19:55:30 +02:00
Jairo Llopis
dfe51f5c2b Reorder reference docs
`api/index.md` docs were repeating the reference ones. No sense. DRY.
2020-09-17 17:26:35 +00:00
Tim Gates
fd27ae32d1 docs: Fix simple typo, subrpoject -> subproject
There is a small typo in copier/cli.py.

Should read `subproject` rather than `subrpoject`.
2020-09-14 09:50:19 +02:00
Jairo Llopis
6e7cff8b37 Allow multidoc copier.yml with glob include
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.
2020-09-05 11:22:42 +00:00
Jairo Llopis
913e67392d More readable tests
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.
2020-09-05 11:22:42 +00:00
Timothée Mazzucotelli
0a40b0b853 Update docs dependencies versions 2020-09-05 10:22:43 +01:00
Nat Noordanus
d949d51ad3 Replace makefile with poe tasks & update CONTRIBUTING.md
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
2020-08-21 14:02:49 +01:00
Jairo Llopis
df33b2953b FIx publish workflow
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.
2020-08-17 07:45:16 +00:00
Jairo Llopis
2cf5be072a Print all logs to sys.stderr v5.1.0 2020-08-17 07:59:25 +01:00
Jairo Llopis
307fd8aea0 Forbid downgrades
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
2020-08-14 13:56:32 +01:00
Jairo Llopis
d6324eb7a4 Fix admonitions
Little bug that made these docs look like code instead of normal docs.
v5.0.0
2020-08-13 12:14:48 +00:00
Jairo Llopis
de12eec1f4 Make latest the default docs location
This will reduce friction while testing docs in PRs until https://github.com/pawamoy/mkdocstrings/issues/144 is fixed.
2020-08-13 11:58:46 +00:00
Jairo Llopis
9ebb6c5de3 Update dependencies
Workaround for a version conflict that breaks the readthedocs builds, as seen in https://readthedocs.org/api/v2/build/11653917.txt
2020-08-13 11:45:18 +00:00
Jairo Llopis
1e464dad0f Add --prereleases support
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.
2020-08-13 11:45:18 +00:00
Jairo Llopis
8be4bbe93a Better docs for CLI
- 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.
2020-08-13 10:17:23 +00:00
Jairo Llopis
cbd57f0a0c Add docs dependencies to dev dependencies
This is a workaround for https://github.com/python-poetry/poetry/issues/2555 that should be reverted after it's fixed and a new poetry is released.
2020-08-13 10:17:23 +00:00
Jairo Llopis
52febbd5ea Attempt to enable caching on Windows
Apply suggestion from https://github.com/actions/cache/issues/315#issuecomment-671424348.
2020-08-13 09:50:14 +01:00
Jairo Llopis
5456e33e99 Allow to trigger CI manually
This is needed to test the master branch if it was automerged (which doesn't trigger workflows).

Also I fixed the link for that CI badge.
2020-08-12 11:02:06 +00:00
Jairo Llopis
cdb563a96d Add 4-space indentation to .md files
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.
2020-08-10 12:59:07 +00:00
Jairo Llopis
a456f59b7a A little polish on docs
- 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.
v4.1.0
2020-08-10 11:27:52 +00:00
Jairo Llopis
a957f0e53c Disable cache for windows
Applying workaround for problem described at https://github.com/actions/cache/issues/315#issuecomment-670940889 that makes the windows build take over 20 minutes. Better to use no cache then.
2020-08-08 15:27:56 +00:00
Jairo Llopis
16be9557a3 Unify cache location across OS
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.
2020-08-08 15:27:56 +00:00
Jairo Llopis
9bd9400580 Windows fixes
- 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.
2020-08-08 15:27:56 +00:00
Jairo Llopis
a0d6173347 Skip irreverent test on Mac OSX
TODO Get some happy Mac hacker that fixes this for us.
2020-08-08 15:27:56 +00:00
Jairo Llopis
00791ccf7d Fix encoding error in Mac OS
Partially revert 97c75e44025c5ecf886cf67d428161a0c61e7f29.
2020-08-08 15:27:56 +00:00
Jairo Llopis
5bc6cf69e8 Test other OSes
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.
2020-08-08 15:27:56 +00:00
Jairo Llopis
1cc201e0cb Make Copier work with Git 2.28
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.
2020-08-04 16:17:29 +00:00
Timothée Mazzucotelli
fda2ef3e6e s/pykong/copier-org
Also add a "thanks" mention for @pykong 🙂
2020-08-04 09:47:33 +01:00
Jairo Llopis
3296b4ccc0 Link docs
🎉 We have docs! https://copier.readthedocs.io/
2020-08-03 13:10:47 +00:00
Jairo Llopis
55de4aeeea Add readthedocs configuration 2020-08-03 14:02:13 +01:00
Alexandre Chaussier
173db40a1d Docs: Add a warning about "!include" usage with YAML files 2020-08-03 13:09:58 +01:00
Timothée Mazzucotelli
b94b7f4042 Prettify code 2020-07-31 15:02:58 +02:00
Timothée Mazzucotelli
3ad2c67a20 Autodoc 2020-07-31 15:02:58 +02:00
Jairo Llopis
45c5f0d90b Fix failing tests
https://github.com/jpscaletti/siht disappeared, so these tests were failing now. Fixed by using own copier repo to test.
v4.0.2
2020-07-21 08:26:35 +00:00
Jairo Llopis
544c248bf1 Avoid templated defaults counting as init data
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.
2020-07-21 08:26:35 +00:00
Jairo Llopis
403183c78d Fix wrong prompt when updating
#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
v4.0.1
2020-06-23 09:33:43 +00:00
Jairo Llopis
823f3a1935 Remove dst fixture
This is redundant with pytest's native `tmp_path` fixture, so we use that one instead now.
2020-06-23 07:58:03 +00:00
Jairo Llopis
3af3209f5f Update dependencies and changelog for release v4.0.0 2020-06-18 11:34:18 +01:00
Jairo Llopis
65b03c0c5a Support pre-migration scripts that alter .copier-answers.yml file
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
2020-06-18 10:07:25 +01:00
Jairo Llopis
f7aee2857d Remember answer procedence
- `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
2020-06-18 09:24:58 +01:00
Jairo Llopis
25f8d796bf Remove semver
Fix #199.
2020-06-18 09:03:58 +01:00
Jairo Llopis
5ebb15fa60
Merge pull request #220 from yelizariev/patch-1
README: fix markdown format
2020-06-17 09:45:39 +01:00
Ivan Yelizariev
bca532a308
README: fix markdown format 2020-06-17 11:35:24 +05:00
Jairo Llopis
2f087bdc31 Merge pull request #193 from pawamoy/feat-add-subdirectory-option
Add subdirectory option
v3.2.0
2020-05-27 08:34:37 +01:00
Timothée Mazzucotelli
c4b38a1ec6 Add subdirectory option
Co-authored-by: Jairo Llopis <Yajo@users.noreply.github.com>
2020-05-20 19:41:10 +02:00
Jairo Llopis
968f975fbb
Merge pull request #212 from Tecnativa/automerge
Add automerge
2020-05-20 08:58:13 +01:00
Jairo Llopis
23d5e68859
Add automerge
This will ease maintenance.
2020-05-20 08:55:07 +01:00
Jairo Llopis
6008380b58
Merge pull request #211 from pawamoy/remove-semver-warning
Stop using deprecated semver.compare function
2020-05-20 08:52:40 +01:00