Skip to content

Commit

Permalink
fix: small code and code style fixes
Browse files Browse the repository at this point in the history
Co-authored-by: Sigurd Spieckermann <[email protected]>
  • Loading branch information
freundTech and sisp committed Feb 15, 2024
1 parent 1c1b644 commit f62dbf5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions copier/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ class Task:
cmd: Union[str, Sequence[str]]
extra_env: Env = field(default_factory=dict)
extra_context: Dict[str, Any] = field(default_factory=dict)
condition: str = field(default="true")
working_directory: str = field(default=".")
condition: str = "true"
working_directory: Path = Path(".")


@dataclass
Expand Down Expand Up @@ -406,15 +406,13 @@ def migration_tasks(
# New configuration format
if isinstance(migration, (str, list)):
result.append(Task(cmd=migration, extra_env=extra_env, extra_context=extra_context))

else:
condition = migration.get("when", "true")
working_directory = migration.get("working_directory", ".")
if "version" in migration:
current = parse(migration["version"])
if not (self.version >= current > from_template.version):
continue

extra_env = {
**extra_env,
"VERSION_CURRENT": migration["version"],
Expand Down Expand Up @@ -497,8 +495,9 @@ def tasks(self) -> Sequence[Task]:
if isinstance(task, (str, list)):
tasks.append(Task(cmd=task, extra_env=extra_env))
elif isinstance(task, dict):
tasks.append(Task(cmd=task["command"], extra_env=extra_env, extra_context=extra_context, condition=task.get("when", "true"), working_directory=task.get("working_directory", ".")))

tasks.append(Task(cmd=task["command"], extra_env=extra_env, extra_context=extra_context, condition=task.get("when", "true"), working_directory=Path(task.get("working_directory", "."))))
else:
raise NotImplementedError("Unsupported tasks format")
return tasks

@cached_property
Expand Down

0 comments on commit f62dbf5

Please sign in to comment.