38 Commits

Author SHA1 Message Date
Sigurd Spieckermann
f374fd9baa build: migrate from Poetry to uv 2025-04-22 12:20:23 +02:00
David Linke
ca764db9c6
fix: explicitly specify file encoding for windows (#2007)
* Test for #2006; conflict in unicode content on windows

* Read files in binary mode to avoid encoding problems
2025-03-09 21:12:41 +00:00
Jairo Llopis
fd23923b5c
style(ruff-format): enable and reformat Python files
Until now, only linting was enabled. My failure.

I added this setting to widen the code style automation. I also enabled [keep-runtime-typing](https://docs.astral.sh/ruff/settings/#lint_pyupgrade_keep-runtime-typing) because we use Pydantic.

Finally, I executed the new formatting over all the project.
2024-12-03 13:59:00 +01:00
Sigurd Spieckermann
0258635da7 fix: support Git config without user identity 2024-07-30 13:40:17 +02:00
Adrian Freund
d6f226f2b3
feat: add simpler migrations configuration syntax (#1510) 2024-05-15 11:19:11 +02:00
danieleades
0c6b0b96fe
build(typing): enable 'strict' mypy linting (#1527)
---------

Co-authored-by: Timothée Mazzucotelli <dev@pawamoy.fr>
2024-03-23 12:58:20 +01:00
danieleades
878c4d4f40
style: add 'flake-future-annotations' lint group (#1506)
* add ruff 'flake8-future-annotations' (FA) lint group
2024-02-22 06:19:17 +00:00
Timothée Mazzucotelli
c47ce39157 tests: Move git_init function into helpers 2023-11-22 15:34:24 +00:00
Sigurd Spieckermann
a82c0ad6bf
refactor: drop support for Python 3.7 (#1252) 2023-07-18 19:59:05 +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
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
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
Sigurd Spieckermann
482db41c90
refactor(typing): use abstract container types where possible (#832) 2022-10-06 12:11:32 +00:00
Paul Moore
05c5f09034
feat: simplify the format of the question prompt (#689)
Closes https://github.com/copier-org/copier/issues/674
2022-06-04 11:02:37 +00:00
Paul Moore
c5d46100a6
tests: refactor the tests to only depend on the prompt format in one place (#682)
* refactor(tests): refactor the tests to only depend on the prompt format in one place

* Address review comments
2022-05-28 08:42:19 +00:00
Timothée Mazzucotelli
3425db5b96 tests: Use datetime.fromisoformat 2021-12-17 22:22:37 +01:00
Jacob Straszynski
600ebdb492
feat: raise CopierAnswersInterrupt on partial answers (#476)
* includes a unit-y test in it's own file, tests/test_interrupts.
* includes an integration test that verifies that we don't dump
  a stacktrace. E.g. this test will fail if CopierAnswersInterrupt no
  longer subclasses KeyboardInterrupt.
* update changelog with CopierAnswersInterrupt
2021-11-15 13:29:57 +00:00
Timothée Mazzucotelli
b3860dd274
fix: Fix unicode error on binary files (#436)
* fix: Fix unicode error on binary files

If a unicode decode error is raised
while trying to compile a file as a Jinja2 template,
and the templates suffix is empty,
we fallback to copying this file as is.

Fixes #433.
2021-08-03 17:19:04 +01:00
Jairo Llopis
0500a617c0 test: make spawned processes debuggable
Implement the workaround from https://github.com/microsoft/debugpy/issues/596#issuecomment-824643237 to allow debugging pexpect subprocesses.
2021-04-23 17:45:25 +01:00
Jairo Llopis
1482de4972
wip 2021-03-05 17:33:11 +00:00
Jairo Llopis
0441b86f0c
Refactor (#314)
* Refactor
* Fix #110.
* Rewrite test_config_exclude, test_config_exclude_overridden and test_config_include. These tests were badly designed, using a monkeypatch that would never happen in the real world, and actually producing false positives. I moved them to test_exclude.py and rewritten to test the what and not the how.
* Fix #214 by removing skip option. Relevant tests use the better skip_if_exists=["**"].
* Remove subdirectory flag from API/CLI. It was confusing and could lead to bad maintenance situations. Fixes #315.
* Remove extra_paths and fix #321
* Remember that you cannot use _copier_conf.src_path as a path now
* use dataclasses
* Create errors module, simplify some tests, fix many others
* Fix some tests, complete EnvOps removal
* Fix #214 and some tests related to it
* Reorder code
* Update docs and imports
* Modularize test_complex_questions
* Interlink worker and questionary a bit better
* Removal of Questionary class, which only had 1 meaningful method that is now merged into Worker to avoid circular dependencies.
* Fix #280 in a simple way: only user answers are type-casted inside API, and CLI transforms all `--data` using YAML always. Predictable.
* Use prereleases correctly.
* Reorder AnswersMap to have a more significative repr.
* Simpler cache for old `Question.get_choices()` method (renamed now).
* fix wrong test
* Fix test_subdirectory
* Fix test_tasks (and remove tests/demo_tasks)
* Fix path filter tests, and move it to test_exclude, where it belongs
* Make test_config pass
* Fix more wrongly designed tests
* Use cached_property backport if needed
* xfail test known to fail on mac
* force posix paths on windows
* Add typing_extensions for python < 3.8
* Sort dependencies in pyproject.toml
* Support python 3.6 str-to-datetime conversion
* Workaround https://bugs.python.org/issue43095
* xfail test_path_filter on windows
* Upgrade mkdocs and other dependencies to fix https://github.com/pawamoy/mkdocstrings/issues/222
* Add missing reference docs.
* Add workaround for https://github.com/pawamoy/mkdocstrings/pull/209
* Docs.
* Remove validators module
* Add workaround for https://github.com/pawamoy/mkdocstrings/issues/225
* Restore docs autorefs as explained in https://github.com/pawamoy/mkdocstrings/issues/226#issuecomment-775413562.
* Workaround https://github.com/pawamoy/pytkdocs/issues/86
2021-02-09 18:22:47 +00:00
Jairo Llopis
c93ef75521 Fix wrong default choice
When updating a project, a choice answer never got a good default value. Now it's properly selected, and interactive behavior is tested.
2020-10-23 10:52:42 +00:00
Jairo Llopis
cda93273c1
Enhanced user input (#260)
* use a new toolkit for user prompting: questionary (patched).
* multiline questions.
* conditional questions.
* new toolkit for ui tests: pexpect.
* fix lots of tests.
* fix windows builds with newer poetry-dynamic-versioning.
* linters and mypy are now tests, to have faster ci.
* update deprecated ci commands.
* removed dependencies from old times.
* Remove toml 0.5+ syntax (dotted keys)
* Use powershell where syntax is compatible
* Change skip to xfail
* xfail pexpect tests on windows. I'm tired of trying to make it work
* more docs
* possibly something more.
2020-10-12 08:56:46 +01: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
6d7ab7f941
Update diff fixes
- 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
2020-04-08 11:51:44 +01:00
Ben Felder
82ddf4adb7
Merged origin/master to solve conflicts. 2019-08-29 22:32:46 +02:00
Ben Felder
69760a583a Cleaned up imports. 2019-08-08 23:16:47 +02:00
Ben Felder
8dbd7e9661 Some fixes to type annotations. 2019-08-08 21:05:05 +02:00
Juan-Pablo Scaletti
1f6f41a246 Fix py35 issues with pathlib 2019-04-05 10:39:20 -05:00
Juan-Pablo Scaletti
5b52b37662 pathlib.Path ALL the paths! 2019-04-03 23:22:25 -05:00
Juan-Pablo Scaletti
9c9f5e7821 black-styled 2019-03-07 22:07:51 -05:00
Juan-Pablo Scaletti
5cea5d7ac7 Voodoo -> Copier 2019-02-11 22:32:34 -05:00
Juan-Pablo Scaletti
e00a3dc466 voodo_setup 2015-03-26 20:55:50 -05:00
Juan-Pablo Scaletti
a17bb52b70 Now you can use variables in your file names and not just for folders. Fix #3 2014-01-10 17:25:26 -05:00
Juan-Pablo Scaletti
5b10715b33 VCS support 2013-08-17 12:15:54 -05:00
Juan-Pablo Scaletti
d2926c210d refactor tests to use only py.test 2013-06-30 13:00:15 -05:00
Juan-Pablo Scaletti
071331a621 Tweak example and add a test for the pretend option 2013-06-30 12:03:06 -05:00
Juan-Pablo Scaletti
9a4c180151 Py3.* ready 2013-06-29 17:28:31 -05:00