From 2cf7ab1c1779dcd95f8e1d0a517458276c1cefb0 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Sat, 7 Jun 2025 20:51:47 -0400 Subject: [PATCH] Fix rustfmt and clippy issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add missing newlines at end of files - Remove trailing whitespace - Use next_back() instead of last() for DoubleEndedIterator - Use &Path instead of &PathBuf for function parameter 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/cli/mod.rs | 2 +- src/main.rs | 22 ++++++++++------------ src/registry/mod.rs | 8 ++++---- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 74eba1a..0f8793e 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -50,4 +50,4 @@ pub enum Commands { /// Show version information Version, -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index d15be6a..cf6f2cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use krust::{ image::ImageBuilder, registry::RegistryClient, }; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use tracing::{error, info}; use tracing_subscriber::EnvFilter; @@ -37,7 +37,7 @@ async fn main() -> Result<()> { } => { let config = Config::load()?; let project_path = path.unwrap_or_else(|| PathBuf::from(".")); - + // Determine the image name let image_ref = if let Some(image) = image { // Use explicit image if provided @@ -72,7 +72,7 @@ async fn main() -> Result<()> { let digest_ref = registry_client .push_image(&image_ref, config_data, layers) .await?; - + // Print only the digest reference to stdout println!("{}", digest_ref); } else { @@ -93,19 +93,17 @@ async fn main() -> Result<()> { Ok(()) } -fn get_project_name(project_path: &PathBuf) -> Result { +fn get_project_name(project_path: &Path) -> Result { let cargo_toml_path = project_path.join("Cargo.toml"); - let content = std::fs::read_to_string(&cargo_toml_path) - .context("Failed to read Cargo.toml")?; - - let manifest: toml::Value = toml::from_str(&content) - .context("Failed to parse Cargo.toml")?; - + let content = std::fs::read_to_string(&cargo_toml_path).context("Failed to read Cargo.toml")?; + + let manifest: toml::Value = toml::from_str(&content).context("Failed to parse Cargo.toml")?; + let name = manifest .get("package") .and_then(|p| p.get("name")) .and_then(|n| n.as_str()) .context("Failed to get package name from Cargo.toml")?; - + Ok(name.to_string()) -} \ No newline at end of file +} diff --git a/src/registry/mod.rs b/src/registry/mod.rs index dbceb22..061c2b8 100644 --- a/src/registry/mod.rs +++ b/src/registry/mod.rs @@ -87,19 +87,19 @@ impl RegistryClient { .context("Failed to push manifest")?; info!("Successfully pushed image to {}", manifest_url); - + // Extract digest from the manifest URL // URL format: https://registry/v2/repo/manifests/sha256:digest let digest = manifest_url .split('/') - .last() + .next_back() .context("Failed to extract digest from manifest URL")?; - + // Build the full image reference with digest let registry = reference.registry(); let repository = reference.repository(); let digest_ref = format!("{}/{}@{}", registry, repository, digest); - + Ok(digest_ref) } }