pull: renamed command from *get* to *pull*
All checks were successful
CI / build (push) Successful in 1m41s
All checks were successful
CI / build (push) Successful in 1m41s
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
pub mod package_info;
|
pub mod package_info;
|
||||||
|
pub mod pull;
|
||||||
|
|
||||||
pub type ProgressCallback<'a> = Option<&'a dyn Fn(&str, &str, usize, usize)>;
|
pub type ProgressCallback<'a> = Option<&'a dyn Fn(&str, &str, usize, usize)>;
|
||||||
|
|||||||
13
src/main.rs
13
src/main.rs
@@ -6,8 +6,7 @@ use clap::{Command, arg, command};
|
|||||||
|
|
||||||
extern crate flate2;
|
extern crate flate2;
|
||||||
|
|
||||||
mod get;
|
use pkh::pull::pull;
|
||||||
use get::get;
|
|
||||||
|
|
||||||
mod changelog;
|
mod changelog;
|
||||||
use changelog::generate_entry;
|
use changelog::generate_entry;
|
||||||
@@ -30,8 +29,8 @@ fn main() {
|
|||||||
.subcommand_required(true)
|
.subcommand_required(true)
|
||||||
.disable_version_flag(true)
|
.disable_version_flag(true)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("get")
|
Command::new("pull")
|
||||||
.about("Get a source package from the archive or git")
|
.about("Pull a source package from the archive or git")
|
||||||
.arg(
|
.arg(
|
||||||
arg!(-s --series <series> "Target package distribution series").required(false),
|
arg!(-s --series <series> "Target package distribution series").required(false),
|
||||||
)
|
)
|
||||||
@@ -53,7 +52,7 @@ fn main() {
|
|||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
Some(("get", sub_matches)) => {
|
Some(("pull", sub_matches)) => {
|
||||||
let package = sub_matches.get_one::<String>("package").expect("required");
|
let package = sub_matches.get_one::<String>("package").expect("required");
|
||||||
let series = sub_matches.get_one::<String>("series").map(|s| s.as_str());
|
let series = sub_matches.get_one::<String>("series").map(|s| s.as_str());
|
||||||
let dist = sub_matches.get_one::<String>("dist").map(|s| s.as_str());
|
let dist = sub_matches.get_one::<String>("dist").map(|s| s.as_str());
|
||||||
@@ -66,10 +65,10 @@ fn main() {
|
|||||||
.map(|s| s.as_str())
|
.map(|s| s.as_str())
|
||||||
.unwrap_or("");
|
.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);
|
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,
|
package,
|
||||||
version,
|
version,
|
||||||
series,
|
series,
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use std::cmp::min;
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use pkh::package_info;
|
use crate::package_info;
|
||||||
use pkh::package_info::PackageInfo;
|
use crate::package_info::PackageInfo;
|
||||||
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ use log::debug;
|
|||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use pkh::ProgressCallback;
|
use crate::ProgressCallback;
|
||||||
|
|
||||||
fn clone_repo(
|
fn clone_repo(
|
||||||
url: &str,
|
url: &str,
|
||||||
@@ -300,7 +300,7 @@ async fn fetch_archive_sources(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get(
|
pub async fn pull(
|
||||||
package: &str,
|
package: &str,
|
||||||
_version: &str,
|
_version: &str,
|
||||||
series: Option<&str>,
|
series: Option<&str>,
|
||||||
@@ -421,8 +421,8 @@ pub async fn get(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
async fn test_get_package_end_to_end(package: &str, series: Option<&str>, dist: Option<&str>) {
|
async fn test_pull_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.
|
// 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,
|
// For determinism, we require for tests that either a distro or series is specified,
|
||||||
// as no distribution would mean fallback to system distro
|
// as no distribution would mean fallback to system distro
|
||||||
@@ -432,8 +432,8 @@ mod tests {
|
|||||||
let temp_dir = tempfile::tempdir().unwrap();
|
let temp_dir = tempfile::tempdir().unwrap();
|
||||||
let cwd = temp_dir.path();
|
let cwd = temp_dir.path();
|
||||||
|
|
||||||
// Main 'get' command: the one we want to test
|
// Main 'pull' command: the one we want to test
|
||||||
let info = get(package, "", series, "", "", dist, Some(cwd), None)
|
let info = pull(package, "", series, "", "", dist, Some(cwd), None)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -487,34 +487,34 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_get_hello_ubuntu_end_to_end() {
|
async fn test_pull_hello_ubuntu_end_to_end() {
|
||||||
test_get_package_end_to_end("hello", Some("noble"), None).await;
|
test_pull_package_end_to_end("hello", Some("noble"), None).await;
|
||||||
}
|
}
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_get_hello_debian_end_to_end() {
|
async fn test_pull_hello_debian_end_to_end() {
|
||||||
test_get_package_end_to_end("hello", Some("bookworm"), None).await;
|
test_pull_package_end_to_end("hello", Some("bookworm"), None).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_get_2048_universe_ubuntu_end_to_end() {
|
async fn test_pull_2048_universe_ubuntu_end_to_end() {
|
||||||
test_get_package_end_to_end("2048", Some("noble"), None).await;
|
test_pull_package_end_to_end("2048", Some("noble"), None).await;
|
||||||
}
|
}
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_get_1oom_contrib_debian_end_to_end() {
|
async fn test_pull_1oom_contrib_debian_end_to_end() {
|
||||||
test_get_package_end_to_end("1oom", Some("trixie"), None).await;
|
test_pull_package_end_to_end("1oom", Some("trixie"), None).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_get_agg_svn_fallback_ok() {
|
async fn test_pull_agg_svn_fallback_ok() {
|
||||||
test_get_package_end_to_end("agg", Some("trixie"), None).await;
|
test_pull_package_end_to_end("agg", Some("trixie"), None).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_get_hello_debian_latest_end_to_end() {
|
async fn test_pull_hello_debian_latest_end_to_end() {
|
||||||
test_get_package_end_to_end("hello", None, Some("debian")).await;
|
test_pull_package_end_to_end("hello", None, Some("debian")).await;
|
||||||
}
|
}
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_get_hello_ubuntu_latest_end_to_end() {
|
async fn test_pull_hello_ubuntu_latest_end_to_end() {
|
||||||
test_get_package_end_to_end("hello", None, Some("ubuntu")).await;
|
test_pull_package_end_to_end("hello", None, Some("ubuntu")).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user