34 Commits

Author SHA1 Message Date
Sigurd Spieckermann
ef5ea4b212 refactor: rename internal modules with a _ prefix 2025-04-22 13:52:51 +02:00
Sigurd Spieckermann
b42a032f7b style: fix formatter and linter errors 2025-04-22 12:20:23 +02:00
Sigurd Spieckermann
ede686561d test: use helper function to load answers file data 2025-03-07 12:21:36 +01:00
Sigurd Spieckermann
0258635da7 fix: support Git config without user identity 2024-07-30 13:40:17 +02:00
Sigurd Spieckermann
bc1dfc0419 build(typing): add missing type hints 2023-10-01 07:43:04 +01:00
Juan Luis Cano Rodríguez
94067161e8
fix: do not immediately fail if git is not available
Copier has lots of git-related stuff, but it also has features that work without it. It is now a lazy requirement.

Fixes https://github.com/copier-org/copier/issues/312
2023-08-28 17:27:30 +00:00
Sigurd Spieckermann
10fef1bcf9 style: prefer imports from modules 2023-07-17 13:55:51 +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
Sigurd Spieckermann
9346b41177
test: select latest version tag (#1067) 2023-03-30 23:40:06 +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
Jairo Llopis
6ad9fec0a3 fix: ignore template repo tags that aren't valid PEP 440 versions
In https://github.com/pypa/packaging/issues/530 the packaging project stopped suplying legacy versions when a tag wasn't valid. Then, some repos started failing because they were relying on this.

For example, see https://github.com/Tecnativa/doodba-copier-template/issues/361.

This change makes sure that invalid versions are skipped, so people can still update and those repos just keep working.

The workaround until now is to specify a `--vcs-ref` option, to avoid Copier have to checkout the latest tag automatically (which is the code that triggers the bug).

@moduon MT-2379
2023-02-20 13:56:37 +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
Jairo Llopis
67cc4ffde3
feat: nix support
- Provide a dev shell.
- Provide a nix package.
- Provide a nix flake.
- Development environment based on direnv.
- Docs.
- Configure Gitpod to use direnv and nix.
- Configure Cachix out of the box, and document how to use it.
- Add direnv and nix to CI.
- Satisfy some linters that came from Precommix, even when Precommix was later discarded.
- Mark some tests as impure.
- Run only pure tests when building Copier with Nix.
- Add poetry loader to direnv.
- Update contribution guide.
2023-01-18 09:40:08 +00:00
Timothée Mazzucotelli
682f917b2f
feat: expand tilde in template source path (#835) 2022-10-02 16:57:10 +01:00
Timothée Mazzucotelli
9b536a23e0
fix: delete temporary clones after execution automatically (#802)
Co-authored-by: Jairo Llopis <973709+yajo@users.noreply.github.com>
2022-09-27 15:26:07 +00:00
Timothée Mazzucotelli
890ac866a0
fix: git bundle support breaks with relative paths
Resolve path before checking Git bundle.
2022-09-09 16:09:50 +01:00
John
514bd381c4
feat: support passing github or gitlab urls without the .git suffix (#677)
* fix(vcs.py): Added additional values to GIT_PREFIX to accept https:\\github.com and https:\\gitlab.com. Added handler in get_repo() to add .git to the end of the url if it didn't exist and started with one of those two prefixes. Resolves #217

Accounts for passing github or gitlab urls without the .git suffix to prevent vcs.get_repo from returning None

Resolves #217

* test(test_vcs.py): Added tests cases to support accepting https://github.com and https://gitlab.com urls in vcs.get_repo()

* test(test_vcs.py): based on #677 (comment), we expect the returned url to appropriately append .git. Updated test cases to account for this.

* fix(vcs.py): Corrected the argument being passed to the join() method in get_repo to be a single tuple of strings vice multiple strings since join() takes a single iterable as an argument.

* fix(vcs.py): Corrected the elif statement in get_repo() to join the url with ".git" vice GIT_PREFIX since GIT_PREFIX is of type tuple and join() requires an interable of strings as an argument.

* fix(vcs.py): Change GIT_POSTFIX to a string instead of a tuple.

* style(vcs.py and test_vcs.py): cleanup to pass test_lint()

* style(test_vcs.py): cleanup to pass test_lint()

* style(test_vcs.py): cleanup to pass test_lint()
2022-06-18 08:35:37 +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
45c5f0d90b Fix failing tests
https://github.com/jpscaletti/siht disappeared, so these tests were failing now. Fixed by using own copier repo to test.
2020-07-21 08:26:35 +00:00
Jairo Llopis
c7eddc1509
Fix shortcode without .git suffix
Fixes https://github.com/Tecnativa/doodba-copier-template/issues/14
2020-03-25 15:59:00 +00: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
438ef37c4f Feeding path to shutil.rmtree. 2019-07-11 18:55:19 +02:00
Juan-Pablo Scaletti
8088f77751 Fix failing tests in Py35 2019-06-13 09:22:17 -05:00
Juan-Pablo Scaletti
d6e92cd069 Fix the loading of extra_paths from the config
Fix #38
2019-06-09 20:42:19 -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
45c3c9f102 Finish repo migration 2015-12-03 07:13:18 -05:00
Juan-Pablo Scaletti
ca3bdff935 Uses a public git url for testing 2015-03-27 13:03:32 -05:00
Juan-Pablo Scaletti
6ef5d985df fix tests 2015-03-27 10:17:49 -05:00
Juan-Pablo Scaletti
a4011e8c71 fix render tests 2015-03-27 10:09:33 -05:00
Juan-Pablo Scaletti
e00a3dc466 voodo_setup 2015-03-26 20:55:50 -05:00
Juan-Pablo Scaletti
9d8e17a420 React peacefuly to fatal vcs cloning errors 2013-10-08 17:36:21 -05:00
Juan-Pablo Scaletti
de438f37ae Include a command line tool 2013-10-06 17:23:05 -05:00