fix(#2327): handle dismissed reviews like stale (superseded helper)
This commit is contained in:
parent
cd092a8ae4
commit
ce909a00a2
3 changed files with 38 additions and 16 deletions
|
|
@ -120,7 +120,10 @@ fn pr_status(client: &Client, repo: &str, pr: u64) -> Result<()> {
|
|||
"requested_reviewers": requested,
|
||||
"reviews": reviews
|
||||
.iter()
|
||||
.map(|r| serde_json::json!({"user": r.login, "state": r.state, "stale": r.stale}))
|
||||
.map(|r| serde_json::json!({
|
||||
"user": r.login, "state": r.state,
|
||||
"stale": r.stale, "dismissed": r.dismissed,
|
||||
}))
|
||||
.collect::<Vec<_>>(),
|
||||
"last_comment": last
|
||||
.as_ref()
|
||||
|
|
@ -143,12 +146,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.
|
||||
// A *superseded* REQUEST_CHANGES — stale (branch moved since) or
|
||||
// dismissed — no longer applies to the current head, so it doesn't hold
|
||||
// up the verdict.
|
||||
let changes_requested = reviews
|
||||
.iter()
|
||||
.any(|r| r.state == "REQUEST_CHANGES" && !r.stale);
|
||||
.any(|r| r.state == "REQUEST_CHANGES" && !r.superseded());
|
||||
let ready = ci_state == "success" && mergeable == Some(true) && !changes_requested;
|
||||
if ready {
|
||||
Ok(())
|
||||
|
|
@ -315,9 +318,10 @@ fn print_pr(
|
|||
.iter()
|
||||
.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 => "⚠️",
|
||||
// A superseded approval (stale/dismissed) no longer
|
||||
// satisfies branch protection; flag it so the CLI doesn't
|
||||
// read as still-good.
|
||||
"APPROVED" if r.superseded() => "⚠️",
|
||||
"APPROVED" => "✅",
|
||||
"REQUEST_CHANGES" => "❌",
|
||||
_ => "•",
|
||||
|
|
@ -326,6 +330,8 @@ fn print_pr(
|
|||
let state = &r.state;
|
||||
let suffix = if r.stale {
|
||||
" (stale — needs re-review on current head)"
|
||||
} else if r.dismissed {
|
||||
" (dismissed)"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue