Skip to content

Commit

Permalink
fix(bug): poly diff --short (#34)
Browse files Browse the repository at this point in the history
* fix(bug): poly diff --short did only react to changes within the actual project folder

* bump poetry plugin to 1.0.5
  • Loading branch information
DavidVujic authored Nov 16, 2022
1 parent 5b5c318 commit accecff
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions components/polylith/diff/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,30 @@ def print_diff_summary(tag: str, bases: List[str], components: List[str]) -> Non

if bases:
console.print(f"[base]Changed bases[/]: [data]{len(bases)}[/]")


def _changed_projects(
projects_data: List[dict], brick_type: str, bricks: List[str]
) -> set:
res = {
p["name"]: set(p.get(brick_type, [])).intersection(bricks)
for p in projects_data
}

return {k for k, v in res.items() if v}


def print_short_diff(
projects_data: List[dict],
projects: List[str],
bases: List[str],
components: List[str],
) -> None:

a = _changed_projects(projects_data, "components", components)
b = _changed_projects(projects_data, "bases", bases)

res = a | b | set(projects)

console = Console(theme=info_theme)
console.print(",".join(res))
2 changes: 1 addition & 1 deletion components/polylith/poetry/commands/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def handle(self) -> int:
short = self.option("short")

if short:
self.line(",".join(projects))
diff.report.print_short_diff(projects_data, projects, bases, components)
else:
diff.report.print_diff_summary(tag, bases, components)
diff.report.print_detected_changes_in_projects(projects)
Expand Down
2 changes: 1 addition & 1 deletion projects/poetry_polylith_plugin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry-polylith-plugin"
version = "1.0.4"
version = "1.0.5"
description = "A Poetry plugin that adds tooling support for the Polylith Architecture"
authors = ["David Vujic"]
homepage = "https://github.com/davidvujic/python-polylith"
Expand Down

0 comments on commit accecff

Please sign in to comment.