|
62 | 62 | MISSING,
|
63 | 63 | AnyByStrDict,
|
64 | 64 | JSONSerializable,
|
| 65 | + Phase, |
65 | 66 | RelativePath,
|
66 | 67 | StrOrPath,
|
67 | 68 | )
|
@@ -206,6 +207,7 @@ class Worker:
|
206 | 207 | unsafe: bool = False
|
207 | 208 | skip_answered: bool = False
|
208 | 209 | skip_tasks: bool = False
|
| 210 | + phase: Phase = Phase.PROMPT |
209 | 211 |
|
210 | 212 | answers: AnswersMap = field(default_factory=AnswersMap, init=False)
|
211 | 213 | _cleanup_hooks: list[Callable[[], None]] = field(default_factory=list, init=False)
|
@@ -354,6 +356,7 @@ def _render_context(self) -> Mapping[str, Any]:
|
354 | 356 | _copier_conf=conf,
|
355 | 357 | _folder_name=self.subproject.local_abspath.name,
|
356 | 358 | _copier_python=sys.executable,
|
| 359 | + _copier_phase=self.phase.value, |
357 | 360 | )
|
358 | 361 |
|
359 | 362 | def _path_matcher(self, patterns: Iterable[str]) -> Callable[[Path], bool]:
|
@@ -456,6 +459,7 @@ def _render_allowed(
|
456 | 459 |
|
457 | 460 | def _ask(self) -> None: # noqa: C901
|
458 | 461 | """Ask the questions of the questionnaire and record their answers."""
|
| 462 | + self.phase = Phase.PROMPT |
459 | 463 | result = AnswersMap(
|
460 | 464 | user_defaults=self.user_defaults,
|
461 | 465 | init=self.data,
|
@@ -601,6 +605,7 @@ def match_skip(self) -> Callable[[Path], bool]:
|
601 | 605 |
|
602 | 606 | def _render_template(self) -> None:
|
603 | 607 | """Render the template in the subproject root."""
|
| 608 | + self.phase = Phase.RENDER |
604 | 609 | follow_symlinks = not self.template.preserve_symlinks
|
605 | 610 | for src in scantree(str(self.template_copy_root), follow_symlinks):
|
606 | 611 | src_abspath = Path(src.path)
|
@@ -916,6 +921,7 @@ def run_copy(self) -> None:
|
916 | 921 | # TODO Unify printing tools
|
917 | 922 | print("") # padding space
|
918 | 923 | if not self.skip_tasks:
|
| 924 | + self.phase = Phase.TASKS |
919 | 925 | self._execute_tasks(self.template.tasks)
|
920 | 926 | except Exception:
|
921 | 927 | if not was_existing and self.cleanup_on_error:
|
@@ -1015,6 +1021,7 @@ def _apply_update(self) -> None: # noqa: C901
|
1015 | 1021 | ) as old_worker:
|
1016 | 1022 | old_worker.run_copy()
|
1017 | 1023 | # Run pre-migration tasks
|
| 1024 | + self.phase = Phase.MIGRATE |
1018 | 1025 | self._execute_tasks(
|
1019 | 1026 | self.template.migration_tasks("before", self.subproject.template) # type: ignore[arg-type]
|
1020 | 1027 | )
|
@@ -1090,7 +1097,7 @@ def _apply_update(self) -> None: # noqa: C901
|
1090 | 1097 | self._git_initialize_repo()
|
1091 | 1098 | new_copy_head = git("rev-parse", "HEAD").strip()
|
1092 | 1099 | # Extract diff between temporary destination and real destination
|
1093 |
| - # with some special handling of newly added files in both the poject |
| 1100 | + # with some special handling of newly added files in both the project |
1094 | 1101 | # and the template.
|
1095 | 1102 | with local.cwd(old_copy):
|
1096 | 1103 | # Configure borrowing Git objects from the real destination and
|
|
0 commit comments