From 4e7f44732627981abeb9d2d58a028e03453164c0 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Mon, 1 Dec 2025 17:57:57 +0100 Subject: [PATCH] pull: renamed command from *get* to *pull* --- src/lib.rs | 1 + src/main.rs | 13 ++++++------ src/{get.rs => pull.rs} | 44 ++++++++++++++++++++--------------------- 3 files changed, 29 insertions(+), 29 deletions(-) rename src/{get.rs => pull.rs} (92%) diff --git a/src/lib.rs b/src/lib.rs index abe4837..d7be731 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ pub mod package_info; +pub mod pull; pub type ProgressCallback<'a> = Option<&'a dyn Fn(&str, &str, usize, usize)>; diff --git a/src/main.rs b/src/main.rs index ac0aad1..ea02a3c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,8 +6,7 @@ use clap::{Command, arg, command}; extern crate flate2; -mod get; -use get::get; +use pkh::pull::pull; mod changelog; use changelog::generate_entry; @@ -30,8 +29,8 @@ fn main() { .subcommand_required(true) .disable_version_flag(true) .subcommand( - Command::new("get") - .about("Get a source package from the archive or git") + Command::new("pull") + .about("Pull a source package from the archive or git") .arg( arg!(-s --series "Target package distribution series").required(false), ) @@ -53,7 +52,7 @@ fn main() { .get_matches(); match matches.subcommand() { - Some(("get", sub_matches)) => { + Some(("pull", sub_matches)) => { let package = sub_matches.get_one::("package").expect("required"); let series = sub_matches.get_one::("series").map(|s| s.as_str()); let dist = sub_matches.get_one::("dist").map(|s| s.as_str()); @@ -66,10 +65,10 @@ fn main() { .map(|s| s.as_str()) .unwrap_or(""); - // Since get is async, we need to block on it + // Since pull is async, we need to block on it let (pb, progress_callback) = ui::create_progress_bar(&multi); - if let Err(e) = rt.block_on(get( + if let Err(e) = rt.block_on(pull( package, version, series, diff --git a/src/get.rs b/src/pull.rs similarity index 92% rename from src/get.rs rename to src/pull.rs index 031cb66..64846ae 100644 --- a/src/get.rs +++ b/src/pull.rs @@ -2,8 +2,8 @@ use std::cmp::min; use std::error::Error; use std::path::Path; -use pkh::package_info; -use pkh::package_info::PackageInfo; +use crate::package_info; +use crate::package_info::PackageInfo; use std::process::Command; @@ -11,7 +11,7 @@ use log::debug; use regex::Regex; -use pkh::ProgressCallback; +use crate::ProgressCallback; fn clone_repo( url: &str, @@ -300,7 +300,7 @@ async fn fetch_archive_sources( Ok(()) } -pub async fn get( +pub async fn pull( package: &str, _version: &str, series: Option<&str>, @@ -421,8 +421,8 @@ pub async fn get( mod tests { use super::*; - async fn test_get_package_end_to_end(package: &str, series: Option<&str>, dist: Option<&str>) { - // This test verifies that 'pkh get' clones the repo and fetches the tarball. + async fn test_pull_package_end_to_end(package: &str, series: Option<&str>, dist: Option<&str>) { + // This test verifies that 'pkh pull' clones the repo and fetches the tarball. // For determinism, we require for tests that either a distro or series is specified, // as no distribution would mean fallback to system distro @@ -432,8 +432,8 @@ mod tests { let temp_dir = tempfile::tempdir().unwrap(); let cwd = temp_dir.path(); - // Main 'get' command: the one we want to test - let info = get(package, "", series, "", "", dist, Some(cwd), None) + // Main 'pull' command: the one we want to test + let info = pull(package, "", series, "", "", dist, Some(cwd), None) .await .unwrap(); @@ -487,34 +487,34 @@ mod tests { } #[tokio::test] - async fn test_get_hello_ubuntu_end_to_end() { - test_get_package_end_to_end("hello", Some("noble"), None).await; + async fn test_pull_hello_ubuntu_end_to_end() { + test_pull_package_end_to_end("hello", Some("noble"), None).await; } #[tokio::test] - async fn test_get_hello_debian_end_to_end() { - test_get_package_end_to_end("hello", Some("bookworm"), None).await; + async fn test_pull_hello_debian_end_to_end() { + test_pull_package_end_to_end("hello", Some("bookworm"), None).await; } #[tokio::test] - async fn test_get_2048_universe_ubuntu_end_to_end() { - test_get_package_end_to_end("2048", Some("noble"), None).await; + async fn test_pull_2048_universe_ubuntu_end_to_end() { + test_pull_package_end_to_end("2048", Some("noble"), None).await; } #[tokio::test] - async fn test_get_1oom_contrib_debian_end_to_end() { - test_get_package_end_to_end("1oom", Some("trixie"), None).await; + async fn test_pull_1oom_contrib_debian_end_to_end() { + test_pull_package_end_to_end("1oom", Some("trixie"), None).await; } #[tokio::test] - async fn test_get_agg_svn_fallback_ok() { - test_get_package_end_to_end("agg", Some("trixie"), None).await; + async fn test_pull_agg_svn_fallback_ok() { + test_pull_package_end_to_end("agg", Some("trixie"), None).await; } #[tokio::test] - async fn test_get_hello_debian_latest_end_to_end() { - test_get_package_end_to_end("hello", None, Some("debian")).await; + async fn test_pull_hello_debian_latest_end_to_end() { + test_pull_package_end_to_end("hello", None, Some("debian")).await; } #[tokio::test] - async fn test_get_hello_ubuntu_latest_end_to_end() { - test_get_package_end_to_end("hello", None, Some("ubuntu")).await; + async fn test_pull_hello_ubuntu_latest_end_to_end() { + test_pull_package_end_to_end("hello", None, Some("ubuntu")).await; } }