clippy: apply auto-fixable warnings across workspace (closes #265 partial)
This commit is contained in:
parent
56d0b02c2f
commit
30d82148e0
18 changed files with 83 additions and 102 deletions
|
|
@ -93,7 +93,7 @@ pub async fn run(socket: PathBuf, is_manager: bool) {
|
|||
let url = format!("{forge_url}/api/v1/user");
|
||||
fetch_json(&client, &url, &token)
|
||||
.await
|
||||
.and_then(|v| v["login"].as_str().map(|s| s.to_owned()))
|
||||
.and_then(|v| v["login"].as_str().map(std::borrow::ToOwned::to_owned))
|
||||
.unwrap_or_default()
|
||||
};
|
||||
if own_login.is_empty() {
|
||||
|
|
@ -184,7 +184,7 @@ fn truncate(s: &str, max: usize) -> String {
|
|||
/// Map a Forgejo review state to a readable action label.
|
||||
/// Returns `None` for non-review states (regular comments have no `state` field;
|
||||
/// `PENDING` means the review was saved but not submitted yet).
|
||||
/// Forgejo review states: "APPROVED", "REQUEST_CHANGES", "COMMENT", "PENDING".
|
||||
/// Forgejo review states: "APPROVED", "`REQUEST_CHANGES`", "COMMENT", "PENDING".
|
||||
fn review_state_label(state: &str) -> Option<&str> {
|
||||
match state {
|
||||
"APPROVED" => Some("approved"),
|
||||
|
|
@ -204,7 +204,7 @@ fn review_state_label(state: &str) -> Option<&str> {
|
|||
/// - New item: `[new issue #N repo] title\nurl: ...\nassignee: user`
|
||||
/// - State: `[PR merged #N repo] title\nurl: ...\nassignee: user`
|
||||
///
|
||||
/// Assignees (and, for PRs, requested_reviewers) are appended unconditionally
|
||||
/// Assignees (and, for PRs, `requested_reviewers`) are appended unconditionally
|
||||
/// on all issue/PR notifications (closes #256).
|
||||
///
|
||||
/// Number is extracted from `html_url` last path segment before any `#`.
|
||||
|
|
@ -246,10 +246,10 @@ async fn format_notification(
|
|||
|
||||
// Always fetch subject detail for assignee/reviewer metadata (#256).
|
||||
// Keeps agents informed of current ownership without a follow-up fetch.
|
||||
let subject = if !subject_api_url.is_empty() {
|
||||
fetch_json(client, subject_api_url, token).await
|
||||
} else {
|
||||
let subject = if subject_api_url.is_empty() {
|
||||
None
|
||||
} else {
|
||||
fetch_json(client, subject_api_url, token).await
|
||||
};
|
||||
|
||||
let is_pr = matches!(notif_type, "Pull Request" | "Pull");
|
||||
|
|
@ -328,10 +328,10 @@ async fn format_notification(
|
|||
// Review submission on a PR.
|
||||
let kind = format!("PR {review_label}{num}{repo}");
|
||||
let mut out = format!("[{kind}] {title}\nurl: {url}");
|
||||
if !body_text.is_empty() {
|
||||
out.push_str(&format!("\n\n{author}: {}", truncate(body_text, BODY_TRUNCATE)));
|
||||
} else {
|
||||
if body_text.is_empty() {
|
||||
out.push_str(&format!("\n\nreviewer: {author}"));
|
||||
} else {
|
||||
out.push_str(&format!("\n\n{author}: {}", truncate(body_text, BODY_TRUNCATE)));
|
||||
}
|
||||
out.push_str(&meta_suffix);
|
||||
Some(out)
|
||||
|
|
@ -457,12 +457,9 @@ async fn poll_once(
|
|||
let body_opt = format_notification(client, token, notif, own_login).await;
|
||||
|
||||
// None means self-echo — mark read silently, no delivery.
|
||||
let body = match body_opt {
|
||||
Some(b) => b,
|
||||
None => {
|
||||
mark_read(client, forge_url, token, id).await;
|
||||
continue;
|
||||
}
|
||||
let body = if let Some(b) = body_opt { b } else {
|
||||
mark_read(client, forge_url, token, id).await;
|
||||
continue;
|
||||
};
|
||||
|
||||
let delivered = if is_manager {
|
||||
|
|
@ -501,9 +498,9 @@ async fn poll_once(
|
|||
// when HIVE_FORGE_KEEP_SUBSCRIPTIONS=1 — triage and other firehose
|
||||
// consumers set this to retain broad repo visibility.
|
||||
let reason = notif["reason"].as_str().unwrap_or("");
|
||||
if !keep_subscriptions && reason == "subscribed" {
|
||||
if let Some(repo) = notif["repository"]["full_name"].as_str() {
|
||||
if !unsubbed_repos.contains(repo) {
|
||||
if !keep_subscriptions && reason == "subscribed"
|
||||
&& let Some(repo) = notif["repository"]["full_name"].as_str()
|
||||
&& !unsubbed_repos.contains(repo) {
|
||||
let unsub_url = format!("{forge_url}/api/v1/repos/{repo}/subscription");
|
||||
match client
|
||||
.delete(&unsub_url)
|
||||
|
|
@ -523,8 +520,6 @@ async fn poll_once(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue