Skip to content

Commit

Permalink
Add checkout strategy to report.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbsds committed Jun 8, 2024
1 parent 14339ad commit dca2c71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion nixpkgs_review/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess
from collections.abc import Callable
from pathlib import Path
from typing import Literal

from .nix import Attr
from .utils import info, link, warn
Expand Down Expand Up @@ -90,10 +91,12 @@ def write_error_logs(attrs: list[Attr], directory: Path) -> None:

class Report:
def __init__(
self, system: str, attrs: list[Attr], extra_nixpkgs_config: str
self, system: str, attrs: list[Attr], extra_nixpkgs_config: str, *,
checkout: Literal["merge", "commit"] = "merge",
) -> None:
self.system = system
self.attrs = attrs
self.checkout = checkout
self.broken: list[Attr] = []
self.failed: list[Attr] = []
self.non_existent: list[Attr] = []
Expand Down Expand Up @@ -144,6 +147,7 @@ def serialize_attrs(attrs: list[Attr]) -> list[str]:
{
"system": self.system,
"pr": pr,
"checkout": self.checkout,
"extra-nixpkgs-config": self.extra_nixpkgs_config,
"broken": serialize_attrs(self.broken),
"non-existent": serialize_attrs(self.non_existent),
Expand All @@ -162,6 +166,8 @@ def markdown(self, pr: int | None) -> str:
cmd += f" pr {pr}"
if self.extra_nixpkgs_config:
cmd += f" --extra-nixpkgs-config '{self.extra_nixpkgs_config}'"
if self.checkout != "merge":
cmd += f" --checkout {self.checkout}"

msg = f"Result of `{cmd}` run on {self.system} [1](https://github.com/Mic92/nixpkgs-review)\n"

Expand Down
2 changes: 1 addition & 1 deletion nixpkgs_review/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def start_review(
os.environ["NIXPKGS_REVIEW_ROOT"] = str(path)
if pr:
os.environ["PR"] = str(pr)
report = Report(self.system, attr, self.extra_nixpkgs_config)
report = Report(self.system, attr, self.extra_nixpkgs_config, checkout=self.checkout.name.lower())
report.print_console(pr)
report.write(path, pr)

Expand Down

0 comments on commit dca2c71

Please sign in to comment.