170 Commits

Author SHA1 Message Date
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
Zhiliang Wu
19474b1789 docs: fix jinja-extension link in faq 2023-05-30 19:33:06 +01:00
Jairo Llopis
070527e9b7 docs: clarify new update and overwrite behaviors 2023-05-30 07:34:22 +01:00
Sigurd Spieckermann
6e3a11ee2a docs: add reference to jinja2-jsonschema extension 2023-05-18 15:55:54 +01:00
Sigurd Spieckermann
e829bb5d2d docs: replace run_auto() by run_copy() 2023-05-18 11:30:12 +01:00
Jairo Llopis
2c5ff9e9b7 refactor(update): default to inline markers and 3 lines of context
Now that the inline mode is out of experimental, it turns out to provide a better default behavior than the good old rej mode. Mostly when context is increased to 3 lines or more.

BREAKING CHANGE: The default update conflict mode is now `inline` instead of `rej`.

BREAKING CHANGE: By default, updates now consider 3 lines of context instead of just 1.
2023-05-17 11:56:13 +01: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
Mitch Negus
c79482580e
docs: fix filesystem view to match text (and homepage) (#1136) 2023-05-14 07:19:03 +00:00
Sigurd Spieckermann
f6f37ab4fb
feat: support conditional choices (#1010)
Choices can now be validated with a custom inline jinja template.

Disabled choices won't be selectable, and they display a message telling why.
2023-05-04 09:13:18 +01:00
Jairo Llopis
09cc9953d1
docs: clarify what's invoke
Fix https://github.com/copier-org/copier/issues/1095.
2023-04-19 17:42:48 +01:00
Jairo Llopis
1709d677ee feat: customizable update accuracy
Until today, the updatediff algorithm always used just 1 line of context when detecting conflicts. This was because:

- Solving conflicts wasn't very ergonomic with those `.rej` files around.
- More lines meant too many conflicts usually.

However, it made the diff detection less accurate.

With this change, we allow the users to configure that algorithm. Since they have now the `--context inline` option, more conflicts isn't so much of a problem.

@moduon MT-2638
2023-04-17 12:59:28 +01:00
Sigurd Spieckermann
c0e356bf28 docs(configuring): fix typo 2023-04-17 12:56:27 +01:00
Nils de Bruin
4ecd0ce6c6 Update configuring.md
Changed ' to " as the statement dit not work
2023-04-17 12:53:08 +01:00
Jairo Llopis
689dd8bbb0 docs: explain how to leverage nix with docker
Many folks are not very comfortable with nix yet, so let's document how they can use it in their pipelines with more widely-known tools such as Docker and Podman.

Fixes https://github.com/copier-org/copier/issues/457.
2023-04-07 17:13:39 +01:00
Jairo Llopis
e34bcda48b fix: include dirty local changes when copying HEAD
This was the intended and documented behavior, but at some point it got broken.

Well, now it's tested and it works.

Besides, there's a new FAQ to avoid further surprises.

Fixes https://github.com/copier-org/copier/issues/787
2023-04-07 11:55:59 +01:00
Sigurd Spieckermann
065d6ba1d0
fix: require answer for questions without default value (#958)
When questions didn't have a default answer, the interactive behavior was confusing.

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

BREAKING CHANGE: All default answers must be explicit now.
2023-04-07 08:09:27 +01:00
Adrian Freund
0f610be801
feat: support preserving symlinks when copying templates (#938)
* feat: Preserve symlinks when copying templates

* test: Add tests for symlink copying
2023-04-07 08:03:17 +01:00
Sigurd Spieckermann
a230e4f4d6
docs: add advice on detecting Git repos (#1046) 2023-04-06 06:42:52 +01:00
Sigurd Spieckermann
266139bff4
feat: allow imports in inline templates (#986)
* feat: import Jinja templates/macros relative to template root

* feat: add `joinpath()` function to Jinja globals

* fix: use POSIX paths for Jinja imports/includes

* docs: fix `copier.yml` examples
2023-04-02 15:37:40 +00:00
Sigurd Spieckermann
474be856c1
docs: use tree fence for filesystem trees (#998)
* docs: use tree fence for filesystem trees

* docs: remove dashed lines in filesystem tree
2023-02-25 07:23:14 +00:00
Sigurd Spieckermann
c9e9c100ec fix(cli): use --conflict flag only in copier update subcommand 2023-02-21 21:21:01 +00:00
Sigurd Spieckermann
881a27e48a docs: fix filesystem tree 2023-02-20 19:45:19 +00:00
Jairo Llopis
0f517212eb docs: clarify that you can use copier on preexisting projects
Fix https://github.com/copier-org/copier/issues/955.
2023-02-16 07:20:25 +00:00
Sigurd Spieckermann
6c02cb0a41
feat: exclude nothing by default when using subdirectory 2023-02-02 11:23:56 +00:00
Adrien Berchet
05c92b42b3
fix: warn users against using shallow clones as template source
* refactor: check if the repository is a shallow clone

* refactor: emit a warning for shallow clones

* docs: add faq entry for high resource consumption with shallow clone

* refactor: define a specific warning for shallow clones

* fix: lint after rebase
2023-01-27 13:12:48 +00:00
Raphael Krupinski
20a13b98f4
feat: add native OS directory separator variable in _copier_conf.sep to allow generating dynamic directory structures
* feat(Worker): make sure the parent directory of the target file exists before writing to it
* feat(_copier_conf): add directory separator (os.sep) to _copier_conf

Fix #692
2023-01-27 12:11:11 +00:00
Sigurd Spieckermann
3d211e1dae docs(updating): fix typos/punctuation/grammar 2023-01-25 07:26:18 +00:00
Sigurd Spieckermann
5685c0cab4 docs: update note on Jinja defaults for Copier 7+ 2023-01-10 09:19:24 +00:00
Xuan Hu
a1c882e0ba docs: No redundant empty lines for _copier_answers.
Signed-off-by: Xuan Hu <i@huxuan.org>
2022-12-20 11:28:10 +00:00
Jairo Llopis
1ac529ad5a docs: missing bullet point 2022-12-19 19:18:32 +00:00
Mark van Holsteijn
2c6e2b711f docs: add regex validator example
as requested in 
https://github.com/copier-org/copier/discussions/892
2022-12-19 19:18:32 +00:00
Barry Hart
504301c28e
feat: experimental inline conflict markers when updating
Fixes #613 

Based on #627, but:

* Supports both old (`.rej` files) and new (inline markers) conflict behavior

* Update a test to test both rej and inline conflict resolution

* Update some tests to explicitly specify "rej" conflict mode

* Add documentation for the two conflict modes

* keeping only 3-way merge

Co-authored-by: Oleh Prypin <oprypin@users.noreply.github.com>
Co-authored-by:
Thierry Guillemot <tguillemot@users.noreply.github.com>
Co-authored-by: Barry Hart <barry.hart@zoro.com>
Co-authored-by: Jairo Llopis <yajo.sk8@gmail.com>
Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
2022-11-14 05:09:23 +00:00
Sigurd Spieckermann
6f2749f165 docs: fix invalid anchor link 2022-11-11 16:32:34 +00:00
Timothée Mazzucotelli
b88cc97fc1 docs: Add missing dash in CLI flag docs 2022-11-07 18:47:40 +00:00
Sigurd Spieckermann
6f6208be9a docs: improve section on including other YAML files 2022-10-28 14:25:51 +00:00
Sascha Desch
12bd54239c docs: add rules for merging of multiple documents 2022-10-27 08:37:39 +01:00
Jairo Llopis
8cb181aa5e
docs: don't lie
Fix #838 by not saying tasks can be overridden by API. It's not true.
2022-10-09 07:32:48 +01:00
Sigurd Spieckermann
1f40ddaac2 docs: replace default argument value N/A by [] for lists 2022-10-03 20:46:46 +01:00
Sigurd Spieckermann
2f714559e6 docs: use empty list as default value
Co-authored-by: Jairo Llopis <973709+yajo@users.noreply.github.com>
2022-09-30 05:12:34 +01:00
Sigurd Spieckermann
171293a0fe docs: add _secret_questions setting 2022-09-30 05:12:34 +01:00
Sigurd Spieckermann
bd766ba7c5 docs: unify YAML code block indentation 2022-09-24 13:07:57 +01:00
Tomasz Pluskiewicz
8b43355889 clarify the --vcs-ref HEAD usage
closes #787
2022-09-15 17:11:41 +01:00
Sigurd Spieckermann
a3ded92e9d docs: fix migrations config indentation 2022-09-12 17:56:03 +01:00
Sigurd Spieckermann
e682269cd5 docs: unify shell code blocks 2022-09-09 16:05:20 +01:00
Sigurd Spieckermann
befe8c5ea5 docs: always use ordered list marker "1." 2022-09-09 16:04:20 +01:00
Sigurd Spieckermann
e43f5855c4 docs: add missing language to code fences 2022-09-08 18:38:42 +01:00
Sigurd Spieckermann
3f28e816bb docs(faq): convert "choices" items to lowercase 2022-09-06 16:34:08 +01:00
Sigurd Spieckermann
5a6d930a45 docs: update Jinja2 docs URL to v3.1.x 2022-08-28 09:18:17 +01:00
Sigurd Spieckermann
fc6bb03a6d docs: fix spelling 2022-08-26 09:47:49 +01:00
Talley Lambert
6fcd7e02b8
feat: add validator field to Question (#719)
* docs: add note to docstring

* feat: print spawn logs on failure, and fix failure in test

The test was failing because it turns out that `tui` won't print letters that must not change, when running an interactive TUI.

I changed the error message for something that will force all letters to change. This way it works as expected.

Co-authored-by: Jairo Llopis <yajo.sk8@gmail.com>
2022-08-06 15:48:21 +00:00