Skip to content

Commit

Permalink
Merge pull request #442 from lucasew/20241224-no-headers
Browse files Browse the repository at this point in the history
pr: add flag --no-headers
  • Loading branch information
Mic92 authored Dec 24, 2024
2 parents eb4f1b1 + ad49edb commit 23f9219
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
5 changes: 5 additions & 0 deletions nixpkgs_review/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def pr_flags(
action="store_true",
help="Post the nixpkgs-review results as a PR comment",
)
pr_parser.add_argument(
"--no-headers",
action="store_true",
help="Do not render the header in the markdown report",
)
pr_parser.set_defaults(func=pr_command)
return pr_parser

Expand Down
1 change: 1 addition & 0 deletions nixpkgs_review/cli/pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def pr_command(args: argparse.Namespace) -> str:
nixpkgs_config=nixpkgs_config,
extra_nixpkgs_config=args.extra_nixpkgs_config,
num_parallel_evals=args.num_parallel_evals,
show_header=not args.no_headers,
)
contexts.append((pr, builddir.path, review.build_pr(pr)))
except NixpkgsReviewError as e:
Expand Down
26 changes: 15 additions & 11 deletions nixpkgs_review/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ def __init__(
self,
attrs_per_system: dict[str, list[Attr]],
extra_nixpkgs_config: str,
show_header: bool = True,
*,
checkout: Literal["merge", "commit"] = "merge",
) -> None:
self.show_header = show_header
self.attrs = attrs_per_system
self.checkout = checkout

Expand Down Expand Up @@ -198,17 +200,19 @@ def json(self, pr: int | None) -> str:
)

def markdown(self, pr: int | None) -> str:
msg = "## `nixpkgs-review` result\n\n"
msg += "Generated using [`nixpkgs-review`](https://github.com/Mic92/nixpkgs-review).\n\n"

cmd = "nixpkgs-review"
if pr is not None:
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"Command: `{cmd}`\n"
msg = ""
if self.show_header:
msg += "## `nixpkgs-review` result\n\n"
msg += "Generated using [`nixpkgs-review`](https://github.com/Mic92/nixpkgs-review).\n\n"

cmd = "nixpkgs-review"
if pr is not None:
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"Command: `{cmd}`\n"

for system, report in self.system_reports.items():
msg += "\n---\n"
Expand Down
3 changes: 3 additions & 0 deletions nixpkgs_review/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __init__(
checkout: CheckoutOption = CheckoutOption.MERGE,
sandbox: bool = False,
num_parallel_evals: int = 1,
show_header: bool = True,
) -> None:
if skip_packages_regex is None:
skip_packages_regex = []
Expand Down Expand Up @@ -144,6 +145,7 @@ def __init__(
self.nixpkgs_config = nixpkgs_config
self.extra_nixpkgs_config = extra_nixpkgs_config
self.num_parallel_evals = num_parallel_evals
self.show_header = show_header

def _process_aliases_for_systems(self, system: str) -> set[str]:
match system:
Expand Down Expand Up @@ -359,6 +361,7 @@ def start_review(
attrs_per_system,
self.extra_nixpkgs_config,
checkout=self.checkout.name.lower(), # type: ignore[arg-type]
show_header=self.show_header,
)
report.print_console(pr)
report.write(path, pr)
Expand Down

0 comments on commit 23f9219

Please sign in to comment.