feat(#2327): surface forgejo stale/dismissed review flags in pr-status/reviews/merge

This commit is contained in:
damocles 2026-07-10 14:50:19 +02:00 committed by mara
commit cd092a8ae4
4 changed files with 77 additions and 26 deletions

View file

@ -120,7 +120,7 @@ fn pr_status(client: &Client, repo: &str, pr: u64) -> Result<()> {
"requested_reviewers": requested,
"reviews": reviews
.iter()
.map(|(l, s)| serde_json::json!({"user": l, "state": s}))
.map(|r| serde_json::json!({"user": r.login, "state": r.state, "stale": r.stale}))
.collect::<Vec<_>>(),
"last_comment": last
.as_ref()
@ -143,9 +143,12 @@ fn pr_status(client: &Client, repo: &str, pr: u64) -> Result<()> {
}
// Merge-readiness: CI green, mergeable, and nobody requesting changes.
// A *stale* REQUEST_CHANGES was made against an older head — the branch
// moved since, so forgejo marks it stale and it no longer blocks the
// current head; don't let it hold up the verdict.
let changes_requested = reviews
.iter()
.any(|(_, verdict)| verdict == "REQUEST_CHANGES");
.any(|r| r.state == "REQUEST_CHANGES" && !r.stale);
let ready = ci_state == "success" && mergeable == Some(true) && !changes_requested;
if ready {
Ok(())
@ -280,7 +283,7 @@ fn print_pr(
ci_state: &str,
ci_statuses: &[Value],
requested: &[String],
reviews: &[(String, String)],
reviews: &[super::ReviewInfo],
last_comment: Option<&(String, String)>,
) {
println!("PR #{pr}: {title}");
@ -310,13 +313,23 @@ fn print_pr(
} else {
let rendered: Vec<String> = reviews
.iter()
.map(|(login, verdict)| {
let mark = match verdict.as_str() {
.map(|r| {
let mark = match r.state.as_str() {
// A stale approval no longer satisfies branch protection;
// flag it so the CLI doesn't read as still-good.
"APPROVED" if r.stale => "⚠️",
"APPROVED" => "",
"REQUEST_CHANGES" => "",
_ => "",
};
format!("{mark} {login}: {verdict}")
let login = &r.login;
let state = &r.state;
let suffix = if r.stale {
" (stale — needs re-review on current head)"
} else {
""
};
format!("{mark} {login}: {state}{suffix}")
})
.collect();
println!(" reviews: {}", rendered.join(", "));