Skip to content

Commit b05ce14

Browse files
committed
PR dashboard: ignore merge-from-base commits made by non-authors
The is_substantive() filter excluded "Update branch" merge commits from the latest-event determination, but treated all merge commits the same regardless of who made them, and the LLM-rendered context still surfaced them in the "Last N commits" listing and used their timestamp for "Last commit pushed". Refine the rule to only ignore merge commits authored by someone other than the PR author (e.g. an approver clicking "Update branch" on someone else's PR, as on open-telemetry#18090). Author-driven merges of base into the PR remain substantive. Apply the same rule to the rendered commit listing and last_commit_date.
1 parent edbcfeb commit b05ce14

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

.github/scripts/pull-request-dashboard.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,14 @@ def fetch_pr_context(
418418

419419
# Last substantive event = last event whose body is non-empty OR whose
420420
# kind is not "review:COMMENTED" (state changes always count). Merge
421-
# commits (≥2 parents — e.g. "Update branch" merging base into the PR)
422-
# don't count as substantive: they don't move the conversation forward.
421+
# commits (≥2 parents) by someone *other* than the author — e.g. an
422+
# approver clicking "Update branch" — don't count as substantive: they
423+
# don't move the conversation forward and shouldn't be confused with
424+
# the author addressing feedback.
423425
def is_substantive(e: dict[str, Any]) -> bool:
424426
if e["kind"].startswith("review:") and e["kind"] != "review:COMMENTED":
425427
return True
426-
if e.get("is_merge"):
428+
if e.get("is_merge") and (e.get("login") or "").lower() != author.lower():
427429
return False
428430
return bool((e.get("body") or "").strip())
429431

@@ -432,16 +434,34 @@ def is_substantive(e: dict[str, Any]) -> bool:
432434

433435
# Commit summaries (subject only) for the brief table in the rendered
434436
# context. Full commit messages and diffs travel via timeline events.
437+
# Merge commits authored by someone other than the PR author (e.g. an
438+
# approver clicking "Update branch") are flagged so the model doesn't
439+
# treat them as the author addressing feedback.
435440
commit_rows = []
436441
for c in recent_commits:
437-
sha = (c.get("sha") or "")[:7]
442+
sha_full = c.get("sha") or ""
443+
sha = sha_full[:7]
438444
msg = (c.get("commit") or {}).get("message", "").splitlines()[0] if c.get("commit") else ""
439445
a = c.get("author") or {}
440446
commit_login = a.get("login") or ((c.get("commit") or {}).get("author") or {}).get("name") or "?"
441447
commit_date = ((c.get("commit") or {}).get("author") or {}).get("date") or ""
442-
commit_rows.append({"sha": sha, "msg": msg, "author": commit_login, "date": commit_date})
448+
is_non_author_merge = (
449+
sha_full in merge_shas
450+
and (commit_login or "").lower() != author.lower()
451+
)
452+
commit_rows.append({
453+
"sha": sha,
454+
"msg": msg,
455+
"author": commit_login,
456+
"date": commit_date,
457+
"is_non_author_merge": is_non_author_merge,
458+
})
443459

444-
last_commit_date = parse_ts(commit_rows[-1]["date"]) if commit_rows else None
460+
# "Last commit pushed" is meant to surface real author activity, so
461+
# skip non-author merge commits (e.g. approvers clicking "Update
462+
# branch") when picking the timestamp.
463+
real_rows = [r for r in commit_rows if not r["is_non_author_merge"]]
464+
last_commit_date = parse_ts(real_rows[-1]["date"]) if real_rows else None
445465

446466
# Checks summary.
447467
failing = [c for c in checks if (c.get("state") or "").upper() in ("FAILURE", "ERROR")]
@@ -543,7 +563,8 @@ def render_context(ctx: dict[str, Any]) -> str:
543563
# Commits
544564
lines.append(f"Last {len(ctx['commits'])} commits (oldest first):")
545565
for c in ctx["commits"]:
546-
lines.append(f" {c['sha']} {c['date'][:10]} @{c['author']}: {truncate(c['msg'], 120)}")
566+
suffix = " [merge from base by non-author — not substantive activity]" if c.get("is_non_author_merge") else ""
567+
lines.append(f" {c['sha']} {c['date'][:10]} @{c['author']}: {truncate(c['msg'], 120)}{suffix}")
547568
lines.append("")
548569

549570
# Last substantive event highlight

0 commit comments

Comments
 (0)