From dddd01d2d5636aa8ca8aceb3581595be6fa000c2 Mon Sep 17 00:00:00 2001 From: edef Date: Mon, 20 Jun 2022 11:25:51 +0000 Subject: fleet/pkgs/naut: clean up formatting Change-Id: I74844b6a35fe1fd76af87fe994a346ee92eb3ccb --- fleet/pkgs/naut/src/main.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'fleet') diff --git a/fleet/pkgs/naut/src/main.rs b/fleet/pkgs/naut/src/main.rs index 361c212..ed38a96 100644 --- a/fleet/pkgs/naut/src/main.rs +++ b/fleet/pkgs/naut/src/main.rs @@ -42,7 +42,7 @@ async fn main() -> Result<()> { spawn(async move { if let Err(e) = conn.await { - eprintln!("Failed to handle request: {}", e); + eprintln!("Failed to handle request: {e}"); } }); } @@ -115,14 +115,14 @@ async fn handle( if r#ref.is_branch() { if new.is_zero() { - lines.push(format!("branch {} deleted (was {})", ref_name, old)); + lines.push(format!("branch {ref_name} deleted (was {old})")); } else { let mut walker = repo.revwalk()?; walker.set_sorting(Sort::REVERSE)?; walker.push(new)?; if old.is_zero() { - lines.push(format!("new branch created: {}", ref_name)); + lines.push(format!("new branch created: {ref_name}")); // We cannot use repo.head directly, as that comes resolved already. let head = repo.find_reference("HEAD")?; @@ -157,14 +157,13 @@ async fn handle( if !commits.is_empty() { lines.push(format!( - "{} {} pushed to {}", + "{} {} pushed to {ref_name}", commits.len(), if commits.len() == 1 { "commit" } else { "commits" }, - ref_name )); for commit in commits { @@ -178,16 +177,13 @@ async fn handle( } } } else if r#ref.is_tag() { - if new.is_zero() { - lines.push(format!("tag {} deleted (was {})", ref_name, old)) + lines.push(if new.is_zero() { + format!("tag {ref_name} deleted (was {old})") } else if old.is_zero() { - lines.push(format!("commit {} tagged as {}", new, ref_name)) + format!("commit {new} tagged as {ref_name}") } else { - lines.push(format!( - "tag {} modified (was {}, now {})", - ref_name, old, new - )) - } + format!("tag {ref_name} modified (was {old}, now {new})") + }); } else { return Err(anyhow!( "Received a reference that's neither a branch nor tag: {}", -- cgit 1.4.1