Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions scripts/pr_file_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
deleted, renamed, or on a branch not checked out locally).

`DIRECTORY.md` is treated specially and reported in its own section at the very
bottom. It is auto-generated, so nearly every PR touches it and it would
bottom. It is auto-generated, so nearly every PR touches it, and it would
otherwise dominate the "possible merge conflicts" list and distract busy
maintainers. A merge conflict caused only by `DIRECTORY.md` is trivial to clear:
choose __accept both__ in the GitHub UI. The bottom section therefore separates
Expand All @@ -37,8 +37,8 @@
Requirements: gh (GitHub CLI), authenticated (`gh auth login`)

Usage:
./pr_file_map.py
./pr_file_map.py > report.md
scripts/pr_file_map.py
scripts/pr_file_map.py > report.md
"""

import json
Expand Down Expand Up @@ -101,7 +101,7 @@ def git_root() -> Path | None:
def script_display_path() -> Path:
"""This script's path relative to the git root (falls back to absolute)."""
script_path = Path(__file__).resolve()
if (root := git_root()) is not None:
if root := git_root():
try:
return script_path.relative_to(root.resolve())
except ValueError:
Expand Down Expand Up @@ -179,7 +179,11 @@ def render_directory_section(
f"### `{len(directory_only)}` PRs whose only overlap is "
f"`{DIRECTORY_FILE}` (safe to accept both)\n"
)
print(" ".join(f"#{n}" for n in directory_only) if directory_only else "_None._")
print(
"- " + ", ".join(f"#{n}" for n in directory_only)
if directory_only
else "_None._"
)
print(
f"\n### `{len(directory_plus_other)}` PRs that also overlap on other "
"files (need a review or rebase)\n"
Expand Down Expand Up @@ -253,7 +257,7 @@ def main() -> None:
# --- Render GitHub-flavored Markdown ---
print("# Open Pull Request File Map\n")
print(f"- Script: `{script_display_path()}`")
print(f"- Generated (UTC): `{datetime.now(UTC).isoformat()}`")
print(f"- Generated: `{datetime.now(UTC):%d %b %Y at %H:%M} {UTC}`")
print(f"- Number of PRs: `{pr_count}`")
print(f"- File touches (PR x file): `{touch_count}`")
print(f"- Distinct files touched: `{distinct_count}`")
Expand Down
Loading