Let the caller state the project's version

--version replaces the commit hash on the cover and the project page, for
generate and from-folder alike. Without it the report still falls back to
repository_version from the metadata, else the scanned commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
alexanderandClaude Opus 5.5 committed 2026-09-25 12:22:45 +02:00
1 parent ffcd68f9f8
commit 0ace2e1803
4 files changed
+31 -10

No files matched your search

+14 -1
View File
@@ -34,6 +34,8 @@ class GenerateProperties(BaseModel):
the renderer chose; leaving it out writes into ``reports/``.
project: The name of the scanned project, as the report states it.
manufacturer: Who makes the scanned product, as the report states it.
version: The version of the scanned project, as the report states it.
Replaces the commit hash the metadata names when given.
storage_config: The store the scan's artifacts are read from.
"""
@@ -41,6 +43,9 @@ class GenerateProperties(BaseModel):
path: Path | None = Field(default=None, description="Where to write the PDF report.")
project: str | None = Field(default=None, description="The name of the scanned project.")
manufacturer: str | None = Field(default=None, description="The manufacturer of the scanned product.")
version: str | None = Field(
default=None, description="The version of the scanned project. Replaces the commit hash when given."
)
storage_config: StorageConfiguration
@@ -54,6 +59,7 @@ class FolderProperties(BaseModel):
path: Where to write the PDF, as above.
project: The name of the scanned project, as above.
manufacturer: Who makes the scanned product, as above.
version: The version of the scanned project, as above.
"""
artifacts: Path = Field(description="Folder of exported artifacts to build the report from.")
@@ -63,6 +69,9 @@ class FolderProperties(BaseModel):
path: Path | None = Field(default=None, description="Where to write the PDF report.")
project: str | None = Field(default=None, description="The name of the scanned project.")
manufacturer: str | None = Field(default=None, description="The manufacturer of the scanned product.")
version: str | None = Field(
default=None, description="The version of the scanned project. Replaces the commit hash when given."
)
class GeneratedReport(BaseModel):
@@ -102,6 +111,7 @@ def generate(properties: GenerateProperties) -> GeneratedReport:
properties.path,
project=properties.project,
manufacturer=properties.manufacturer,
version=properties.version,
)
@@ -125,6 +135,7 @@ def from_folder(properties: FolderProperties) -> GeneratedReport:
properties.path,
project=properties.project,
manufacturer=properties.manufacturer,
version=properties.version,
write_metrics=True,
)
@@ -135,6 +146,7 @@ def _report(
*,
project: str | None = None,
manufacturer: str | None = None,
version: str | None = None,
write_metrics: bool = False,
) -> GeneratedReport:
"""Render the collected artifacts and write the result.
@@ -147,6 +159,7 @@ def _report(
path: Where the caller asked for the PDF, if anywhere in particular.
project: The project name the caller supplied, if any.
manufacturer: The manufacturer the caller supplied, if any.
version: The version the caller supplied, if any.
write_metrics: Whether to write ``metrics.json`` beside the PDF.
Returns:
@@ -156,7 +169,7 @@ def _report(
PipelineError: The report cannot be built or the destination not written.
"""
metrics = build_metrics(sources)
name, content = render(sources, metrics, project=project, manufacturer=manufacturer)
name, content = render(sources, metrics, project=project, manufacturer=manufacturer, version=version)
destination = _destination(path, name)
try: