13 Commits

Author SHA1 Message Date
Tsvika Shapira
a812e14033
feat: raise new TaskError exception on task errors
Raising `TaskError` instead of `subprocess.CalledProcessError` is backwards compatible, as `TaskError` is a subclass of `subprocess.CalledProcessError`.
2025-04-21 15:13:58 +02:00
Sigurd Spieckermann
83f44cb4b6
feat: disable unsafe features by default and add --UNSAFE switch (#1171)
I've disabled the use of unsafe features (Jinja extensions, migrations, and tasks) by default and added a new CLI switch `--UNSAFE` which enables them. Templates that don't use unsafe features are unaffected by this change. But Copier will raise an error for templates that do use unsafe features unless the `--UNSAFE` flag is passed.

I've not added an interactive prompt that asks for consent for using unsafe features because I think it's not clear how to distinguish between interactive prompting and raising an error when `--UNSAFE` is not passed. For this, I think Copier would need a switch that clearly states whether interactive or non-interactive mode is desired. Currently, `--defaults` implies this for questions.

Fixes https://github.com/copier-org/copier/issues/1137

BREAKING CHANGE: Copier raises an error when a template uses unsafe features unless the `--UNSAFE` switch is passed
2023-06-01 18:22:40 +00:00
Jairo Llopis
6996b9cc7a feat: add recopy command and function
This new command allows to reapply a template, keeping old answers but discarding subproject evolution.

It is useful when there are bugs replaying an old version of the template, or when the subproject has drifted too much from the template and you need to reset it.

BREAKING CHANGE: All CLI calls to Copier must now include the subcommand as the 1st argument. For example, `copier` must become now `copier update`; also `copier ./tpl ./dst` must become `copier copy ./tpl ./dst`.

BREAKING CHANGE: All flags must go after the subcommand now. For example, `copier -r HEAD update ./dst` must now become `copier update -r HEAD ./dst` or `copier update ./dst -r HEAD`.

BREAKING CHANGE: Automatic mode removed. Since now subcommands are required, the automatic mode is removed.

BREAKING CHANGE: Deprecated `copier.copy` function is removed. Use `copier.run_copy`, `copier.run_update` or `copier.run_recopy` explicitly as needed.

Fix https://github.com/copier-org/copier/issues/1081
Close https://github.com/copier-org/copier/issues/1082
2023-05-17 11:56:13 +01:00
Sigurd Spieckermann
17135c5f34 fix(cleanup): don't clean up local template in parent folder 2023-04-03 06:02:04 +01:00
Sigurd Spieckermann
5029b6e7a9
test: add type hints and clean up (#985)
* refactor(tests): add type hints and clean up

* fix: import `Protocol` from `typing-extensions` when using Python 3.7

* fix: import `Literal` from `typing-extensions` when using Python 3.7

* refactor(tests): create template and subproject directory using `tmp_path_factory` fixture

* refactor(tests): use OS-agnostic file path separator

* refactor(tests): use `/` separator for `skip_if_exists` paths

* style: fix formatting error

* refactor(tests): expect POSIX path for local repo URL
2023-03-21 16:31:11 +00:00
Yajo
5db76d1df8 test: make sure copier won't delete a preexisting folder
This was already happening, but the test is now more complete.

Fix #https://github.com/copier-org/copier/issues/262 by just asserting it was fixed already.
2021-12-10 20:37:05 +00:00
Jairo Llopis
a15da2d511 Run updated pre-commit 2020-10-16 11:47:57 +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
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
Juan-Pablo Scaletti
5d15e9df2f Removes top __init__ file. Fix #56 2019-08-20 13:19:32 -05:00
Juan-Pablo Scaletti
830667c1ad Add a flag to disable the cleanup on error (cleanup enabled by default) 2019-06-13 17:38:48 -05:00
Juan-Pablo Scaletti
8088f77751 Fix failing tests in Py35 2019-06-13 09:22:17 -05:00
Ben Felder
895489586d Implemented cleanup on failure and test. 2019-06-09 14:26:29 +02:00