treewide: format with nightly rustfmt; auto-fix Clippy lints

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I15d9215ab506b37954468d99746098326a6a6964
This commit is contained in:
raf 2026-02-08 02:15:06 +03:00
commit 73919f2f9e
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
30 changed files with 144 additions and 151 deletions

View file

@ -29,6 +29,7 @@ pub struct ApiKeyInfo {
pub last_used_at: Option<chrono::DateTime<chrono::Utc>>,
}
#[must_use]
pub fn hash_api_key(key: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(key.as_bytes());

View file

@ -10,7 +10,7 @@ use tokio::process::Command;
use crate::{error::ApiError, state::AppState};
/// Serve NARInfo for a store path hash.
/// Serve `NARInfo` for a store path hash.
/// GET /nix-cache/{hash}.narinfo
async fn narinfo(
State(state): State<AppState>,
@ -68,7 +68,7 @@ async fn narinfo(
};
let nar_hash = entry.get("narHash").and_then(|v| v.as_str()).unwrap_or("");
let nar_size = entry.get("narSize").and_then(|v| v.as_u64()).unwrap_or(0);
let nar_size = entry.get("narSize").and_then(serde_json::Value::as_u64).unwrap_or(0);
let store_path = entry
.get("path")
.and_then(|v| v.as_str())

View file

@ -186,7 +186,9 @@ async fn compare_evaluations(
// Jobs in both: compare derivation paths
for (name, from_build) in &from_map {
if let Some(to_build) = to_map.get(name) {
if from_build.drv_path != to_build.drv_path {
if from_build.drv_path == to_build.drv_path {
unchanged_count += 1;
} else {
changed_jobs.push(JobChange {
job_name: name.to_string(),
system: to_build.system.clone(),
@ -195,8 +197,6 @@ async fn compare_evaluations(
old_status: format!("{:?}", from_build.status),
new_status: format!("{:?}", to_build.status),
});
} else {
unchanged_count += 1;
}
}
}

View file

@ -93,12 +93,9 @@ async fn stream_build_log(
if active_path.exists() { active_path.clone() } else { final_path.clone() }
};
let file = match tokio::fs::File::open(&path).await {
Ok(f) => f,
Err(_) => {
yield Ok(Event::default().data("Failed to open log file"));
return;
}
let file = if let Ok(f) = tokio::fs::File::open(&path).await { f } else {
yield Ok(Event::default().data("Failed to open log file"));
return;
};
let mut reader = BufReader::new(file);

View file

@ -130,7 +130,7 @@ async fn prometheus_metrics(State(state): State<AppState>) -> Response {
output
.push_str("\n# HELP fc_evaluations_total Total number of evaluations\n");
output.push_str("# TYPE fc_evaluations_total gauge\n");
output.push_str(&format!("fc_evaluations_total {}\n", eval_count));
output.push_str(&format!("fc_evaluations_total {eval_count}\n"));
output.push_str("\n# HELP fc_evaluations_by_status Evaluations by status\n");
output.push_str("# TYPE fc_evaluations_by_status gauge\n");

View file

@ -270,8 +270,7 @@ async fn github_callback(
""
};
let clear_state = format!(
"fc_oauth_state=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0{}",
secure_flag
"fc_oauth_state=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0{secure_flag}"
);
let session_cookie = format!(
"fc_user_session={}; HttpOnly; SameSite=Lax; Path=/; Max-Age={}{}",

View file

@ -130,8 +130,8 @@ struct SearchRequest {
eval_before: Option<DateTime<Utc>>,
// Sorting
/// Sort builds by: created_at, job_name, status, priority (default:
/// created_at)
/// Sort builds by: `created_at`, `job_name`, status, priority (default:
/// `created_at`)
#[serde(rename = "build_sort")]
build_sort: Option<String>,
@ -139,12 +139,12 @@ struct SearchRequest {
#[serde(rename = "order")]
order: Option<String>,
/// Sort projects by: name, created_at (default: name)
/// Sort projects by: name, `created_at` (default: name)
#[serde(rename = "project_sort")]
project_sort: Option<String>,
}
fn default_limit() -> i64 {
const fn default_limit() -> i64 {
20
}

View file

@ -45,7 +45,7 @@ pub struct UserResponse {
impl From<User> for UserResponse {
fn from(u: User) -> Self {
UserResponse {
Self {
id: u.id,
username: u.username,
email: u.email,

View file

@ -403,35 +403,32 @@ async fn handle_gitea_push(
.map_err(ApiError)?;
// Fall back to the other type if not found
let webhook_config = match webhook_config {
Some(c) => c,
None => {
let alt = if forge_type == "gitea" {
"forgejo"
} else {
"gitea"
};
match repo::webhook_configs::get_by_project_and_forge(
&state.pool,
project_id,
alt,
)
.await
.map_err(ApiError)?
{
Some(c) => c,
None => {
return Ok((
StatusCode::NOT_FOUND,
Json(WebhookResponse {
accepted: false,
message: "No Gitea/Forgejo webhook configured for this project"
.to_string(),
}),
));
},
}
},
let webhook_config = if let Some(c) = webhook_config { c } else {
let alt = if forge_type == "gitea" {
"forgejo"
} else {
"gitea"
};
match repo::webhook_configs::get_by_project_and_forge(
&state.pool,
project_id,
alt,
)
.await
.map_err(ApiError)?
{
Some(c) => c,
None => {
return Ok((
StatusCode::NOT_FOUND,
Json(WebhookResponse {
accepted: false,
message: "No Gitea/Forgejo webhook configured for this project"
.to_string(),
}),
));
},
}
};
// Verify signature if configured