From 0784fd95bcca54c01285097eddea01020203e0a4 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 23 Jun 2025 09:05:10 +0200 Subject: clippy: Use strip_prefix instead of start_prefix + manual slicing --- server/src/git_root.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/src/git_root.rs') diff --git a/server/src/git_root.rs b/server/src/git_root.rs index ec741c4..f915095 100644 --- a/server/src/git_root.rs +++ b/server/src/git_root.rs @@ -252,10 +252,10 @@ async fn git_process_prehook( let translation_review_id; - if branch.starts_with("t/") { + if let Some(stripped_branch) = branch.strip_prefix("t/") { // Translation review - translation_review_id = branch[2..].parse::().ok(); + translation_review_id = stripped_branch.parse::().ok(); if translation_review_id.is_none() { error!("{branch}: Invalid translation review branch"); errors.push(format!("{branch}: Invalid translation review branch")); @@ -428,9 +428,9 @@ async fn git_process_posthook( let branch = row.reference.strip_prefix("refs/heads/").unwrap(); - if branch.starts_with("t/") { + if let Some(stripped_branch) = branch.strip_prefix("t/") { // pre-hook already checked format - let id = branch[2..].parse::().unwrap(); + let id = stripped_branch.parse::().unwrap(); match sqlx::query!( "UPDATE translation_reviews SET head=? WHERE project=? AND id=?", -- cgit v1.2.3-70-g09d2