Watch
0
0
Fork
You've already forked hyperhive
0

review classifier: it reads the PR's title and description, and a rule on closing keywords

The controller reads the PR's title and description with the rest of it and
puts both in the run's shared context, ahead of the commits. An empty
description reads as `(none)`. `TryOut` carries them as optional fields, so a
controller that sends none still gets its run answered.

New rule `closes-only-finished-issues`: a description that carries a closing
keyword for an issue and also says the PR leaves part of it undone is a
violation, because the keyword closes the issue when the PR merges.
This commit is contained in:
argus 2026-11-23 00:49:11 +01:00 • committed by mara
commit 8a0615ccfc
3 changed files with 114 additions and 27 deletions

View file

@ -179,6 +179,10 @@ fn open_pulls(pulls: Vec<forgejo_api::structs::PullRequest>) -> Vec<OpenPull> {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PullForReview {
pub head_sha: String,
/// The PR's title.
pub title: String,
/// The PR's description, empty when it has none.
pub description: String,
pub commits: Vec<Commit>,
pub diff: String,
/// Why `diff` is the forge's `.diff`, with 3 lines of context, rather
@ -1481,6 +1485,8 @@ impl Client {
.call(|api| api.repo_get_pull_request(owner, repo, number).into_future())
.await
.with_context(|| format!("read PR {number} of {owner}/{repo}"))?;
let title = pull.title.unwrap_or_default();
let description = pull.body.unwrap_or_default();
let changed_files = pull.changed_files;
let head_sha = pull
.head
@ -1540,6 +1546,8 @@ impl Client {
};
Ok(PullForReview {
head_sha,
title,
description,
commits,
diff,
narrowed,

View file

@ -705,6 +705,8 @@ async fn start(
repo,
pr: run.pr.unsigned_abs(),
head_sha: pull.head_sha.clone(),
title: pull.title,
description: pull.description,
commits: pull.commits,
diff: pull.diff,
classifications: run.classifications,
@ -888,6 +890,8 @@ pub(crate) mod tests {
if (owner, repo, number) == ("o", "r", 7) {
Ok(PullForReview {
head_sha: "abc123".to_owned(),
title: String::new(),
description: String::new(),
commits: Vec::new(),
diff: String::new(),
narrowed: self.narrowed.clone(),
@ -1421,6 +1425,7 @@ classifications:
"no-code-units-in-operator-docs",
"option-in-the-wrong-namespace",
"docs-describe-current-state",
"closes-only-finished-issues",
]
);
}

View file

@ -1139,6 +1139,8 @@ async fn classify(
repo,
pr: req.pr.unsigned_abs(),
head_sha: pull.head_sha,
title: pull.title,
description: pull.description,
commits: pull.commits,
diff: pull.diff,
classifications: rules.classifications,
@ -1801,6 +1803,8 @@ mod tests {
.cloned();
Ok(PullForReview {
head_sha: head.unwrap_or_else(|| "abc123".to_owned()),
title: String::new(),
description: String::new(),
commits: Vec::new(),
diff: String::new(),
narrowed: None,