Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ Visit <https://dev-portal.diamond.ac.uk/create> 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.
Expand Down
3 changes: 0 additions & 3 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ sphinx:

_subdirectory: "template"

_tasks:
- "git init --initial-branch=main"

_migrations:
- version: 2.0.0
before:
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to/update-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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`
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/adopt-existing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Copier will *overwrite* files with the template files. Please check the changes
If you have a [python3-pip-skeleton](https://github.com/DiamondLightSource/python3-pip-skeleton) based project then it is best to adopt the `1.0.0` release of this template, then `copier update` to get to the latest. This is because `copier update` will try and merge file changes across renames done between releases, while `copier copy` cannot. This looks like:

```shell
copier copy https://github.com/DiamondLightSource/python-copier-template.git --trust --vcs-ref=1.0.0 /path/to/existing-project
copier copy https://github.com/DiamondLightSource/python-copier-template.git --vcs-ref=1.0.0 /path/to/existing-project
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"
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/create-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
Expand All @@ -170,7 +171,7 @@ def test_example_repo_updates(tmp_path: Path):
run("git config user.email '[email protected]'")
run("git config user.name 'Your Name'")
run("git commit -am 'Update src'")
run(f"copier update --trust --vcs-ref=HEAD --data-file {TOP}/example-answers.yml")
run(f"copier update --vcs-ref=HEAD --data-file {TOP}/example-answers.yml --trust")
output = run(
# Git directory expected to be different
"diff -ur --exclude=.git "
Expand Down