Skip to content

Commit b1858ca

Browse files
authored
Merge pull request #492 from booxter/include-hash-in-report
Include commit hash under test in the report
2 parents c1f0b26 + 820754a commit b1858ca

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

nixpkgs_review/cli/pr.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def pr_command(args: argparse.Namespace) -> str:
7777
Path,
7878
# Attrs to build for each system
7979
dict[System, list[Attr]],
80+
# PR revision
81+
str | None,
8082
]
8183
] = []
8284

@@ -113,16 +115,24 @@ def pr_command(args: argparse.Namespace) -> str:
113115
num_parallel_evals=args.num_parallel_evals,
114116
show_header=not args.no_headers,
115117
)
116-
contexts.append((pr, builddir.path, review.build_pr(pr)))
118+
contexts.append(
119+
(pr, builddir.path, review.build_pr(pr), review.head_commit)
120+
)
117121
except NixpkgsReviewError as e:
118122
warn(f"https://github.com/NixOS/nixpkgs/pull/{pr} failed to build: {e}")
119123
assert review is not None
120124

121125
all_succeeded = all(
122126
review.start_review(
123-
attrs, path, pr, args.post_result, args.print_result, args.approve_pr
127+
commit,
128+
attrs,
129+
path,
130+
pr,
131+
args.post_result,
132+
args.print_result,
133+
args.approve_pr,
124134
)
125-
for pr, path, attrs in contexts
135+
for pr, path, attrs, commit in contexts
126136
)
127137

128138
if args.no_shell:

nixpkgs_review/report.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def to_file_uri(path: Path) -> str:
235235
class Report:
236236
def __init__(
237237
self,
238+
commit: str | None,
238239
attrs_per_system: dict[str, list[Attr]],
239240
extra_nixpkgs_config: str,
240241
only_packages: set[str],
@@ -246,6 +247,7 @@ def __init__(
246247
*,
247248
checkout: Literal["merge", "commit"] = "merge",
248249
) -> None:
250+
self.commit = commit
249251
self.show_header = show_header
250252
self.max_workers = max_workers
251253
self.attrs = attrs_per_system
@@ -325,6 +327,8 @@ def markdown(self, pr: int | None) -> str:
325327
option_value
326328
)
327329
msg += f"Command: `{cmd}`\n"
330+
if self.commit:
331+
msg += f"Commit: `{self.commit}`\n"
328332

329333
for system, report in self.system_reports.items():
330334
msg += "\n---\n"

nixpkgs_review/review.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def __init__(
149149
self.extra_nixpkgs_config = extra_nixpkgs_config
150150
self.num_parallel_evals = num_parallel_evals
151151
self.show_header = show_header
152+
self.head_commit: str | None = None
152153

153154
def _process_aliases_for_systems(self, system: str) -> set[str]:
154155
match system:
@@ -314,6 +315,7 @@ def build(
314315

315316
def build_pr(self, pr_number: int) -> dict[System, list[Attr]]:
316317
pr = self.github_client.pull_request(pr_number)
318+
self.head_commit = pr["head"]["sha"]
317319

318320
packages_per_system: dict[System, set[str]] | None = None
319321
if self.use_github_eval:
@@ -388,6 +390,7 @@ def build_pr(self, pr_number: int) -> dict[System, list[Attr]]:
388390

389391
def start_review(
390392
self,
393+
commit: str | None,
391394
attrs_per_system: dict[System, list[Attr]],
392395
path: Path,
393396
pr: int | None = None,
@@ -400,6 +403,7 @@ def start_review(
400403
if pr:
401404
os.environ["PR"] = str(pr)
402405
report = Report(
406+
commit,
403407
attrs_per_system,
404408
self.extra_nixpkgs_config,
405409
checkout=self.checkout.name.lower(), # type: ignore[arg-type]
@@ -455,6 +459,7 @@ def review_commit(
455459
) -> None:
456460
branch_rev = fetch_refs(self.remote, branch)[0]
457461
self.start_review(
462+
reviewed_commit,
458463
self.build_commit(branch_rev, reviewed_commit, staged),
459464
path,
460465
print_result=print_result,

0 commit comments

Comments
 (0)