Skip to content

Commit d48d075

Browse files
fix!: Remove need for --trust (#271)
Fixes #270 but introduces a change in behaviour between 3.x and 4.x updates from here on
1 parent dfe17b1 commit d48d075

File tree

7 files changed

+14
-16
lines changed

7 files changed

+14
-16
lines changed

.github/workflows/_example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
- name: Regenerate example
1818
run: |
19-
pipx run copier copy --data-file example-answers.yml --trust --vcs-ref=HEAD . example
19+
pipx run copier copy --data-file example-answers.yml --vcs-ref=HEAD . example
2020
2121
- name: Rewrite copier answers
2222
run: |

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ Visit <https://dev-portal.diamond.ac.uk/create> and you will see a list of templ
4646
You will need to `pip install copier` inside an activated `venv` from python3.11 or later, then you can create a new module via:
4747

4848
```
49-
mkdir /path/to/my-project
50-
# The --trust argument is required to run setup tasks such as initializing a git repository
51-
copier copy --trust https://github.com/DiamondLightSource/python-copier-template.git /path/to/my-project
49+
git init --initial-branch=main /path/to/my-project
50+
# $_ resolves to /path/to/my-project
51+
copier copy https://github.com/DiamondLightSource/python-copier-template.git $_
5252
```
5353

5454
You can also use it via `pipx run copier` if you have that installed.

copier.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ sphinx:
156156

157157
_subdirectory: "template"
158158

159-
_tasks:
160-
- "git init --initial-branch=main"
161-
162159
_migrations:
163160
- version: 2.0.0
164161
before:

docs/how-to/update-template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
To track changes to the upstream template, run
66

77
```
8-
copier update --trust
8+
copier update
99
```
1010

1111
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
3232
- fix issues found by the above
3333
- commit the changes
3434
- update the template
35-
- `copier update --trust`
35+
- `copier update`
3636
- fix any merge conflicts
3737
- validate that the project still works
3838
- `tox -p`

docs/tutorials/adopt-existing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ copier copy https://github.com/DiamondLightSource/python-copier-template.git --t
2222
git diff
2323
# Examine the changes, put back anything you want to keep
2424
git commit -m "Adopt python-copier-template 1.0.0"
25-
copier update --trust /path/to/existing-project
25+
copier update /path/to/existing-project
2626
git diff
2727
# Examine the changes, resolve any merge conflicts
2828
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"
3333
If you have a project with a different structure then it is best to go straight to the latest release:
3434

3535
```shell
36-
copier copy --trust https://github.com/DiamondLightSource/python-copier-template.git /path/to/existing-project
36+
copier copy https://github.com/DiamondLightSource/python-copier-template.git /path/to/existing-project
3737
git diff
3838
# Examine the changes, put back anything you want to keep
3939
git commit -m "Adopt python-copier-template x.x.x"

docs/tutorials/create-new.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Once you have followed the [](./installation) tutorial, you can use `copier` to make a new project from the template:
44

55
```
6-
$ mkdir /path/to/my-project
7-
$ copier copy --trust https://github.com/DiamondLightSource/python-copier-template.git /path/to/my-project
6+
$ git init --initial-branch=main /path/to/my-project
7+
$ copier copy https://github.com/DiamondLightSource/python-copier-template.git $_
88
```
99

1010
This will:

tests/test_example.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
TOP = Path(__file__).absolute().parent.parent
1111

1212

13-
def copy_project(project_path: Path, **kwargs):
13+
def copy_project(project_path: Path, trust: bool = False, **kwargs):
1414
with open(TOP / "example-answers.yml") as f:
1515
answers = yaml.safe_load(f)
1616
answers.update(kwargs)
17+
run_pipe(f"git init {project_path}")
1718
run_copy(
1819
src_path=str(TOP),
1920
dst_path=project_path,
2021
data=answers,
2122
vcs_ref="HEAD",
22-
unsafe=True,
23+
unsafe=trust,
2324
)
2425
run_pipe("git add .", cwd=str(project_path))
2526

@@ -159,7 +160,7 @@ def test_example_repo_updates(tmp_path: Path):
159160
"https://github.com/DiamondLightSource/python-copier-template-example.git"
160161
)
161162
example_path = tmp_path / "example"
162-
copy_project(generated_path)
163+
copy_project(generated_path, trust=True)
163164
run_pipe(f"git clone {example_url} {example_path}")
164165
with open(example_path / ".copier-answers.yml") as f:
165166
d = yaml.safe_load(f)

0 commit comments

Comments
 (0)