diff --git a/.github/workflows/_example.yml b/.github/workflows/_example.yml index ea14af9e..193691ac 100644 --- a/.github/workflows/_example.yml +++ b/.github/workflows/_example.yml @@ -16,7 +16,7 @@ jobs: - name: Regenerate example run: | - pipx run copier copy --data-file example-answers.yml --trust --vcs-ref=HEAD . example + pipx run copier copy --data-file example-answers.yml --vcs-ref=HEAD . example - name: Rewrite copier answers run: | diff --git a/README.md b/README.md index 082e48b0..3a2ae05c 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,9 @@ Visit and you will see a list of templ You will need to `pip install copier` inside an activated `venv` from python3.11 or later, then you can create a new module via: ``` -mkdir /path/to/my-project -# The --trust argument is required to run setup tasks such as initializing a git repository -copier copy --trust https://github.com/DiamondLightSource/python-copier-template.git /path/to/my-project +git init --initial-branch=main /path/to/my-project +# $_ resolves to /path/to/my-project +copier copy https://github.com/DiamondLightSource/python-copier-template.git $_ ``` You can also use it via `pipx run copier` if you have that installed. diff --git a/copier.yml b/copier.yml index ea1ecc1e..ac63bfda 100644 --- a/copier.yml +++ b/copier.yml @@ -156,9 +156,6 @@ sphinx: _subdirectory: "template" -_tasks: - - "git init --initial-branch=main" - _migrations: - version: 2.0.0 before: diff --git a/docs/how-to/update-template.md b/docs/how-to/update-template.md index cfb5829b..5bd1de0f 100644 --- a/docs/how-to/update-template.md +++ b/docs/how-to/update-template.md @@ -5,7 +5,7 @@ To track changes to the upstream template, run ``` -copier update --trust +copier update ``` This will fetch the latest tagged release of the template, and apply any changes to your working copy. It will prompt for answers again, giving your previous answers as the defaults. @@ -32,7 +32,7 @@ The following steps are recommended to update your project, especially for infre - fix issues found by the above - commit the changes - update the template - - `copier update --trust` + - `copier update` - fix any merge conflicts - validate that the project still works - `tox -p` diff --git a/docs/tutorials/adopt-existing.md b/docs/tutorials/adopt-existing.md index 1832869b..7e4ff39b 100644 --- a/docs/tutorials/adopt-existing.md +++ b/docs/tutorials/adopt-existing.md @@ -22,7 +22,7 @@ copier copy https://github.com/DiamondLightSource/python-copier-template.git --t git diff # Examine the changes, put back anything you want to keep git commit -m "Adopt python-copier-template 1.0.0" -copier update --trust /path/to/existing-project +copier update /path/to/existing-project git diff # Examine the changes, resolve any merge conflicts git commit -m "Update to python-copier-template x.x.x" @@ -33,7 +33,7 @@ git commit -m "Update to python-copier-template x.x.x" If you have a project with a different structure then it is best to go straight to the latest release: ```shell -copier copy --trust https://github.com/DiamondLightSource/python-copier-template.git /path/to/existing-project +copier copy https://github.com/DiamondLightSource/python-copier-template.git /path/to/existing-project git diff # Examine the changes, put back anything you want to keep git commit -m "Adopt python-copier-template x.x.x" diff --git a/docs/tutorials/create-new.md b/docs/tutorials/create-new.md index ed5c49da..21d5474d 100644 --- a/docs/tutorials/create-new.md +++ b/docs/tutorials/create-new.md @@ -3,8 +3,8 @@ Once you have followed the [](./installation) tutorial, you can use `copier` to make a new project from the template: ``` -$ mkdir /path/to/my-project -$ copier copy --trust https://github.com/DiamondLightSource/python-copier-template.git /path/to/my-project +$ git init --initial-branch=main /path/to/my-project +$ copier copy https://github.com/DiamondLightSource/python-copier-template.git $_ ``` This will: diff --git a/tests/test_example.py b/tests/test_example.py index a8c0f9ac..3bfe1f61 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -10,16 +10,17 @@ TOP = Path(__file__).absolute().parent.parent -def copy_project(project_path: Path, **kwargs): +def copy_project(project_path: Path, trust: bool = False, **kwargs): with open(TOP / "example-answers.yml") as f: answers = yaml.safe_load(f) answers.update(kwargs) + run_pipe(f"git init {project_path}") run_copy( src_path=str(TOP), dst_path=project_path, data=answers, vcs_ref="HEAD", - unsafe=True, + unsafe=trust, ) run_pipe("git add .", cwd=str(project_path)) @@ -159,7 +160,7 @@ def test_example_repo_updates(tmp_path: Path): "https://github.com/DiamondLightSource/python-copier-template-example.git" ) example_path = tmp_path / "example" - copy_project(generated_path) + copy_project(generated_path, trust=True) run_pipe(f"git clone {example_url} {example_path}") with open(example_path / ".copier-answers.yml") as f: d = yaml.safe_load(f)