|
13 | 13 | import tomli |
14 | 14 | import yaml |
15 | 15 | from copier import Worker |
16 | | -from copier.vcs import get_git |
17 | 16 | from plumbum import local |
18 | 17 |
|
19 | 18 | import project |
|
23 | 22 |
|
24 | 23 | logger = getLogger(__name__) |
25 | 24 |
|
| 25 | + |
| 26 | +def get_git(context_dir: str | Path | None = None): |
| 27 | + """Gets `git` command, or fails if it's not available.""" |
| 28 | + |
| 29 | + GIT_USER_NAME = "Copier" |
| 30 | + GIT_USER_EMAIL = "copier@copier" |
| 31 | + command = local["git"].with_env( |
| 32 | + GIT_AUTHOR_NAME=GIT_USER_NAME, |
| 33 | + GIT_AUTHOR_EMAIL=GIT_USER_EMAIL, |
| 34 | + GIT_COMMITTER_NAME=GIT_USER_NAME, |
| 35 | + GIT_COMMITTER_EMAIL=GIT_USER_EMAIL, |
| 36 | + ) |
| 37 | + if context_dir: |
| 38 | + command = command["-C", context_dir] |
| 39 | + return command |
| 40 | + |
| 41 | + |
26 | 42 | example_folder = Path(project.algorithms.__file__).parent |
27 | 43 | examples: list[str] = [ |
28 | 44 | p.relative_to(example_folder).stem |
@@ -399,7 +415,7 @@ def test_update_project( |
399 | 415 |
|
400 | 416 | with modification(project_root, copier_answers, template_version_used): |
401 | 417 | # Need to commit changes for copier to accept to update. |
402 | | - git = get_git().with_cwd(project_root) |
| 418 | + git = get_git(context_dir=project_root) |
403 | 419 | # TODO: Double-check that these changes only affect the temporary cloned repo, not this |
404 | 420 | # current dev repo. |
405 | 421 | git("config", "commit.gpgsign", "false") |
|
0 commit comments