From 1e7a02e33d1043d4bf65be893355efa6ded47d9c Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Sun, 16 Apr 2023 10:36:43 -0400 Subject: [PATCH] Moved hpk-package all the way back into tree, fixed some clippy lints --- Cargo.lock | 24 +--- Cargo.toml | 9 +- hpk-package/.gitignore | 3 - hpk-package/Cargo.toml | 29 ----- hpk-package/src/lib.rs | 12 -- src/creator/mod.rs | 4 +- src/db/mod.rs | 2 +- src/hooks/mod.rs | 4 +- src/hpk.rs | 1 + src/installer/mod.rs | 119 +++++++++--------- src/item/mod.rs | 26 ++-- src/lib.rs | 9 +- {hpk-package/src => src}/package/arch.rs | 0 .../src => src}/package/dependency.rs | 0 {hpk-package/src => src}/package/mod.rs | 0 {hpk-package/src => src}/package/specs.rs | 0 {hpk-package/src => src}/plist/mod.rs | 0 src/repository/mod.rs | 1 - {hpk-package/src => src}/tar/README.md | 0 {hpk-package/src => src}/tar/error.rs | 0 {hpk-package/src => src}/tar/header.rs | 32 ++--- {hpk-package/src => src}/tar/mod.rs | 39 +++--- {hpk-package/src => src}/tar/node.rs | 4 +- {hpk-package/src => src}/version/gitrev.rs | 0 {hpk-package/src => src}/version/mod.rs | 6 +- {hpk-package/src => src}/version/rapid.rs | 32 ++++- {hpk-package/src => src}/version/semver.rs | 0 {hpk-package/test => test}/1.tar | Bin {hpk-package/test => test}/1.txt | 0 {hpk-package/test => test}/2.tar | Bin 10240 -> 10240 bytes 30 files changed, 171 insertions(+), 185 deletions(-) delete mode 100644 hpk-package/.gitignore delete mode 100644 hpk-package/Cargo.toml delete mode 100644 hpk-package/src/lib.rs rename {hpk-package/src => src}/package/arch.rs (100%) rename {hpk-package/src => src}/package/dependency.rs (100%) rename {hpk-package/src => src}/package/mod.rs (100%) rename {hpk-package/src => src}/package/specs.rs (100%) rename {hpk-package/src => src}/plist/mod.rs (100%) rename {hpk-package/src => src}/tar/README.md (100%) rename {hpk-package/src => src}/tar/error.rs (100%) rename {hpk-package/src => src}/tar/header.rs (96%) rename {hpk-package/src => src}/tar/mod.rs (85%) rename {hpk-package/src => src}/tar/node.rs (97%) rename {hpk-package/src => src}/version/gitrev.rs (100%) rename {hpk-package/src => src}/version/mod.rs (96%) rename {hpk-package/src => src}/version/rapid.rs (89%) rename {hpk-package/src => src}/version/semver.rs (100%) rename {hpk-package/test => test}/1.tar (100%) rename {hpk-package/test => test}/1.txt (100%) rename {hpk-package/test => test}/2.tar (98%) diff --git a/Cargo.lock b/Cargo.lock index 4f579c5..fe7821b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -543,34 +543,22 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "hpk" version = "0.1.0" -dependencies = [ - "clap", - "hpk-package", - "indicatif", - "package-bootstrap", - "rayon", - "ron", - "serde", - "ureq", - "url", - "walkdir", - "zstd", -] - -[[package]] -name = "hpk-package" -version = "0.1.0" -source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk-package.git#e6f392bd7a91ffe3f0b080627e915ea458eade5a" dependencies = [ "chrono", + "clap", "deku", + "indicatif", "libc", + "package-bootstrap", "rayon", "ron", "serde", "sha2", "thiserror", + "ureq", + "url", "walkdir", + "zstd", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ef0e943..288a281 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,12 +21,19 @@ path = "src/bootstrap.rs" required-features = ["bootstrap"] [dependencies] -hpk-package = { git = "https://git.hitchhiker-linux.org/jeang3nie/hpk-package.git" } +deku = "0.16" +libc = "0.2" rayon = "1.7" ron = "0.8" +sha2 = "0.10" +thiserror = "1.0" walkdir = "2.3" zstd = "0.12" +[dependencies.chrono] +version = "0.4" +features = ["serde"] + [dependencies.clap] version = "4.2" optional = true diff --git a/hpk-package/.gitignore b/hpk-package/.gitignore deleted file mode 100644 index 985a402..0000000 --- a/hpk-package/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target -/Cargo.lock -tags diff --git a/hpk-package/Cargo.toml b/hpk-package/Cargo.toml deleted file mode 100644 index 648bf57..0000000 --- a/hpk-package/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "hpk-package" -version = "0.1.0" -edition = "2021" -license = "GPL-3.0-only" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -deku = "0.16" -rayon = "1.7" -ron = "0.8" -sha2 = "0.10" -walkdir = "2.3" -thiserror = "1.0" -libc = "0.2" - -[dependencies.chrono] -version = "0.4" -features = ["serde"] - -[dependencies.serde] -version = "1.0" -features = ["derive"] - -[profile.release] -codegen-units = 1 -lto = true -strip = true diff --git a/hpk-package/src/lib.rs b/hpk-package/src/lib.rs deleted file mode 100644 index fb56ef0..0000000 --- a/hpk-package/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -mod package; -mod plist; -pub mod tar; -mod version; - -pub use { - deku, - package::{Arch, Dependency, Group, Package, Specs, User}, - plist::*, - ron, sha2, - version::*, -}; diff --git a/src/creator/mod.rs b/src/creator/mod.rs index 4c7a5be..cf8d4ae 100644 --- a/src/creator/mod.rs +++ b/src/creator/mod.rs @@ -1,6 +1,6 @@ use { - crate::{Item, ItemError, Package, Plist, Specs}, - hpk_package::{deku::DekuError, tar, Entry}, + crate::{tar, Entry, Item, ItemError, Package, Plist, Specs}, + deku::DekuError, rayon::prelude::{IntoParallelRefIterator, ParallelIterator}, std::{ borrow::BorrowMut, diff --git a/src/db/mod.rs b/src/db/mod.rs index 7858825..888f8e6 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -1,7 +1,7 @@ use { crate::{Arch, Package, Repository, Version}, - hpk_package::ron::{self, ser::PrettyConfig}, rayon::prelude::*, + ron::{self, ser::PrettyConfig}, serde::{Deserialize, Serialize}, std::{ collections::HashMap, diff --git a/src/hooks/mod.rs b/src/hooks/mod.rs index 478b2f9..db7d64b 100644 --- a/src/hooks/mod.rs +++ b/src/hooks/mod.rs @@ -1,7 +1,5 @@ -use hpk_package::{Group, User}; - use { - crate::InstallError, + crate::{Group, InstallError, User}, std::{ path::PathBuf, process::{Command, Output}, diff --git a/src/hpk.rs b/src/hpk.rs index a324e53..741d4c4 100644 --- a/src/hpk.rs +++ b/src/hpk.rs @@ -1,4 +1,5 @@ #![warn(clippy::all, clippy::pedantic)] +#![allow(clippy::missing_errors_doc)] mod cli; use { clap::ArgMatches, diff --git a/src/installer/mod.rs b/src/installer/mod.rs index 7d40a82..8aad365 100644 --- a/src/installer/mod.rs +++ b/src/installer/mod.rs @@ -2,13 +2,12 @@ pub use error::InstallError; use { - crate::{Hooks, Pinstall}, - hpk_package::{ - sha2::{Digest, Sha256}, + crate::{ tar::{Archive, Node}, - Entry, Group, Package, User, + Entry, Group, Hooks, Package, Pinstall, User, }, rayon::prelude::{IntoParallelRefIterator, ParallelIterator}, + sha2::{Digest, Sha256}, std::{ ffi::OsStr, fmt::Write as _, @@ -102,60 +101,63 @@ impl Installer { let package = &self.package; let hooks = Mutex::new(hooks); let s = sender.clone(); - archive.nodes.par_iter().try_for_each_with(s, |sender, node| { - let mut path = path.clone(); - let fpath = node.header.file_path()?; - if let Some(s) = node.header.prefix() { - if s.contains("/share/man/") { - let mut h = hooks.lock().unwrap(); - if !h.contains(&Hooks::Man) { - h.push(Hooks::Man); - } - } else if s.contains("/share/info") { - hooks - .lock() - .unwrap() - .push(Hooks::Info(fpath.to_str().unwrap().to_string())) - } else if s.contains("/share/glib-2.0/schemas") { - let mut h = hooks.lock().unwrap(); - if !h.contains(&Hooks::GlibSchema) { - h.push(Hooks::GlibSchema); + archive + .nodes + .par_iter() + .try_for_each_with(s, |sender, node| { + let mut path = path.clone(); + let fpath = node.header.file_path()?; + if let Some(s) = node.header.prefix() { + if s.contains("/share/man/") { + let mut h = hooks.lock().unwrap(); + if !h.contains(&Hooks::Man) { + h.push(Hooks::Man); + } + } else if s.contains("/share/info") { + hooks + .lock() + .unwrap() + .push(Hooks::Info(fpath.to_str().unwrap().to_string())) + } else if s.contains("/share/glib-2.0/schemas") { + let mut h = hooks.lock().unwrap(); + if !h.contains(&Hooks::GlibSchema) { + h.push(Hooks::GlibSchema); + } } } - } - // Match up a package entry with a tar node - let entry = package - .plist - .entries - .iter() - .find(|&x| match x { - Entry::File { - path, - sha256sum: _, - mode: _, - size: _, - } => path == &fpath, - Entry::Link { path, target: _ } => path == &fpath, - Entry::Directory { path, mode: _ } => path == &fpath, - }) - .unwrap(); - path = path.join(&fpath); - if let Some(parent) = path.parent() { - if !parent.exists() { - fs::create_dir_all(&parent)?; + // Match up a package entry with a tar node + let entry = package + .plist + .entries + .iter() + .find(|&x| match x { + Entry::File { + path, + sha256sum: _, + mode: _, + size: _, + } => path == &fpath, + Entry::Link { path, target: _ } => path == &fpath, + Entry::Directory { path, mode: _ } => path == &fpath, + }) + .unwrap(); + path = path.join(&fpath); + if let Some(parent) = path.parent() { + if !parent.exists() { + fs::create_dir_all(&parent)?; + } } - } - if path.exists() { - if path.is_dir() { - fs::remove_dir(&path)?; - } else if path.is_symlink() || path.is_file() { - fs::remove_file(&path)?; + if path.exists() { + if path.is_dir() { + fs::remove_dir(&path)?; + } else if path.is_symlink() || path.is_file() { + fs::remove_file(&path)?; + } } - } - let msg = extract_entry(entry, node, path)?; - sender.send(msg)?; - Ok::<(), InstallError>(()) - })?; + let msg = extract_entry(entry, node, path)?; + sender.send(msg)?; + Ok::<(), InstallError>(()) + })?; Ok(hooks.into_inner()?) } @@ -252,8 +254,8 @@ fn pop_pinstall( } mod error { - use crate::Hooks; - use hpk_package::tar; + use super::InstallMessage; + use crate::{tar, Hooks}; use std::{ error::Error, fmt, io, @@ -263,7 +265,6 @@ mod error { PoisonError, }, }; - use super::InstallMessage; #[derive(Debug)] pub enum InstallError { @@ -331,8 +332,8 @@ mod error { } } - impl From for InstallError { - fn from(value: hpk_package::tar::Error) -> Self { + impl From for InstallError { + fn from(value: crate::tar::Error) -> Self { Self::Tar(value) } } diff --git a/src/item/mod.rs b/src/item/mod.rs index 06c4fd2..bed1df0 100644 --- a/src/item/mod.rs +++ b/src/item/mod.rs @@ -1,17 +1,19 @@ -use hpk_package::{ +use { + crate::{ + tar::{Error as TarError, Node, Owner}, + Entry, + }, deku::DekuError, sha2::{Digest, Sha256}, - tar::{Error as TarError, Node, Owner}, - Entry, -}; -use std::{ - error::Error, - ffi::OsStr, - fmt::{self, Write}, - fs, - io::{self, Read}, - os::unix::fs::MetadataExt, - path::{Path, PathBuf}, + std::{ + error::Error, + ffi::OsStr, + fmt::{self, Write}, + fs, + io::{self, Read}, + os::unix::fs::MetadataExt, + path::{Path, PathBuf}, + }, }; #[derive(Clone, Debug)] diff --git a/src/lib.rs b/src/lib.rs index ba57571..64ff4aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,15 @@ #![warn(clippy::all, clippy::pedantic)] +#![allow(clippy::must_use_candidate, clippy::missing_errors_doc)] mod creator; mod db; mod hooks; mod installer; mod item; +mod package; +mod plist; mod repository; +pub mod tar; +mod version; use std::path::PathBuf; @@ -12,10 +17,12 @@ pub use { creator::{CreationError, Creator, Message}, db::Database, hooks::{Hooks, Pinstall}, - hpk_package::{tar, Arch, Dependency, GitRev, Package, Plist, Rapid, SemVer, Specs, Version}, installer::{InstallError, InstallMessage, Installer}, item::{Item, ItemError}, + package::{Arch, Dependency, Group, Package, Specs, User}, + plist::{Entry, Plist}, repository::Repository, + version::{GitRev, Rapid, SemVer, Version}, }; const DB: [&str; 4] = ["var", "db", "hpk", "db.ron.zstd"]; diff --git a/hpk-package/src/package/arch.rs b/src/package/arch.rs similarity index 100% rename from hpk-package/src/package/arch.rs rename to src/package/arch.rs diff --git a/hpk-package/src/package/dependency.rs b/src/package/dependency.rs similarity index 100% rename from hpk-package/src/package/dependency.rs rename to src/package/dependency.rs diff --git a/hpk-package/src/package/mod.rs b/src/package/mod.rs similarity index 100% rename from hpk-package/src/package/mod.rs rename to src/package/mod.rs diff --git a/hpk-package/src/package/specs.rs b/src/package/specs.rs similarity index 100% rename from hpk-package/src/package/specs.rs rename to src/package/specs.rs diff --git a/hpk-package/src/plist/mod.rs b/src/plist/mod.rs similarity index 100% rename from hpk-package/src/plist/mod.rs rename to src/plist/mod.rs diff --git a/src/repository/mod.rs b/src/repository/mod.rs index 60c67b1..f4dbaa5 100644 --- a/src/repository/mod.rs +++ b/src/repository/mod.rs @@ -1,6 +1,5 @@ use { crate::Package, - hpk_package::ron, rayon::prelude::*, serde::{Deserialize, Serialize}, std::{ diff --git a/hpk-package/src/tar/README.md b/src/tar/README.md similarity index 100% rename from hpk-package/src/tar/README.md rename to src/tar/README.md diff --git a/hpk-package/src/tar/error.rs b/src/tar/error.rs similarity index 100% rename from hpk-package/src/tar/error.rs rename to src/tar/error.rs diff --git a/hpk-package/src/tar/header.rs b/src/tar/header.rs similarity index 96% rename from hpk-package/src/tar/header.rs rename to src/tar/header.rs index 697f974..aa797ad 100644 --- a/hpk-package/src/tar/header.rs +++ b/src/tar/header.rs @@ -2,7 +2,7 @@ use crate::tar::Error; use deku::prelude::*; use std::{ env, - ffi::CStr, + ffi::{CStr, OsStr}, fmt::{self, Write}, fs::{self, Metadata}, io, @@ -39,8 +39,6 @@ where return FileType::Char; } else if file_type.is_block_device() { return FileType::Block; - } else if file_type.is_fifo() { - return FileType::FIFO; } else if file_type.is_symlink() { return FileType::Symlink; } else if file_type.is_file() { @@ -122,7 +120,7 @@ impl Header { /// # Example /// /// ``` - /// use hpk_package::tar::Header; + /// use hpk::tar::Header; /// /// let header = Header::new("test/1.txt").unwrap(); /// let filename = header.filename().unwrap(); @@ -144,7 +142,7 @@ impl Header { /// /// # Example /// ``` - /// use hpk_package::tar::Header; + /// use hpk::tar::Header; /// /// let header = Header::new("test/1.txt").unwrap(); /// let mode = header.mode().unwrap(); @@ -230,7 +228,7 @@ impl Header { /// /// # Example /// ``` - /// use hpk_package::tar::Header; + /// use hpk::tar::Header; /// /// let header = Header::new("test/1.txt").unwrap(); /// let prefix = header.prefix().unwrap(); @@ -239,10 +237,10 @@ impl Header { pub fn prefix(&self) -> Option { let mut s = String::new(); for c in self.file_prefix { - if c != 0 { - write!(s, "{}", char::from(c)).ok()?; - } else { + if c == 0 { break; + } else { + write!(s, "{}", char::from(c)).ok()?; } } if s.is_empty() { @@ -257,7 +255,7 @@ impl Header { /// # Example /// /// ``` - /// use hpk_package::tar::Header; + /// use hpk::tar::Header; /// use std::path::PathBuf; /// /// let header = Header::new("test/1.txt").unwrap(); @@ -274,6 +272,7 @@ impl Header { Ok(path) } + #[allow(clippy::missing_panics_doc)] pub fn new(filename: &str) -> Result { let mut header = Header::default(); let meta = fs::symlink_metadata(filename)?; @@ -282,7 +281,7 @@ impl Header { // revision allows storing the path prefix separately, with 100 bytes // reserved for the file name and 150 bytes for the rest of the path. let path = PathBuf::from(&filename); - let name = match path.file_name().and_then(|n| n.to_str()) { + let name = match path.file_name().and_then(OsStr::to_str) { Some(n) => n.to_string(), None => { return Err(Error::Io(io::Error::new( @@ -326,7 +325,7 @@ impl Header { /* TODO: Find better way to get username */ let key = "USER"; if let Ok(val) = env::var(key) { - header.username[..val.len()].copy_from_slice(val.as_bytes()) + header.username[..val.len()].copy_from_slice(val.as_bytes()); } /* TODO: Find way to get groupname */ @@ -336,6 +335,7 @@ impl Header { Ok(header) } + #[allow(clippy::missing_panics_doc)] pub fn new_from_meta( filename: &str, meta: &Metadata, @@ -347,7 +347,7 @@ impl Header { // revision allows storing the path prefix separately, with 100 bytes // reserved for the file name and 150 bytes for the rest of the path. let path = PathBuf::from(&filename); - let name = match path.file_name().and_then(|n| n.to_str()) { + let name = match path.file_name().and_then(OsStr::to_str) { Some(n) => n.to_string(), None => { return Err(Error::Io(io::Error::new( @@ -403,7 +403,7 @@ impl Header { /// # Example /// /// ``` - /// use hpk_package::tar::Header; + /// use hpk::tar::Header; /// let header = Header::default(); /// if !header.validate_magic() { /// println!("Magic value is invalid"); @@ -418,7 +418,7 @@ impl Header { /// # Example /// /// ``` - /// use hpk_package::tar::Header; + /// use hpk::tar::Header; /// let header = Header::default(); /// if header.validate_checksum().unwrap() { /// println!("Checksum is valid"); @@ -440,7 +440,7 @@ impl Header { /// # Example /// /// ``` - /// use hpk_package::tar::Header; + /// use hpk::tar::Header; /// let mut header = Header::default(); /// /// /* Fill in header information */ diff --git a/hpk-package/src/tar/mod.rs b/src/tar/mod.rs similarity index 85% rename from hpk-package/src/tar/mod.rs rename to src/tar/mod.rs index f94798d..781946f 100644 --- a/hpk-package/src/tar/mod.rs +++ b/src/tar/mod.rs @@ -4,7 +4,7 @@ use std::{ path::PathBuf, }; -use rayon::prelude::{IntoParallelRefIterator, ParallelIterator, IndexedParallelIterator}; +use rayon::prelude::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; mod error; mod header; @@ -37,7 +37,7 @@ impl Archive { /// /// ``` /// use std::fs::File; - /// use hpk_package::tar::Archive; + /// use hpk::tar::Archive; /// /// let data = Archive::new("test/1.txt").unwrap(); /// @@ -65,7 +65,7 @@ impl Archive { /// # Example /// /// ``` - /// use hpk_package::tar::Archive; + /// use hpk::tar::Archive; /// /// let data = Archive::new("test/1.txt").unwrap(); /// ``` @@ -81,7 +81,7 @@ impl Archive { /// # Example /// /// ``` - /// use hpk_package::tar::Archive; + /// use hpk::tar::Archive; /// /// let mut data = Archive::new("test/1.txt").unwrap(); /// data.append("test/1.txt").unwrap(); @@ -98,7 +98,7 @@ impl Archive { /// # Example /// /// ``` - /// use hpk_package::tar::Archive; + /// use hpk::tar::Archive; /// /// Archive::open("test/1.tar").unwrap(); /// ``` @@ -111,9 +111,9 @@ impl Archive { /// Read a tar archive from anything which implements `io::Read`. /// /// # Example - /// + /// /// ``` - /// use hpk_package::tar::Archive; + /// use hpk::tar::Archive; /// use std::{fs::File, io::BufReader}; /// /// let file = File::open("test/1.tar").unwrap(); @@ -135,7 +135,7 @@ impl Archive { /// # Example /// /// ``` - /// use hpk_package::tar::Archive; + /// use hpk::tar::Archive; /// /// let mut data = Archive::new("test/1.tar").unwrap(); /// data.remove("test/1.tar").unwrap(); @@ -143,7 +143,11 @@ impl Archive { pub fn remove(&mut self, filename: &str) -> Result { let mut name = [0u8; 100]; name[..filename.len()].copy_from_slice(filename.as_bytes()); - if let Some(i) = &self.nodes.par_iter().position_any(|x| x.header.fname == name) { + if let Some(i) = &self + .nodes + .par_iter() + .position_any(|x| x.header.fname == name) + { self.nodes.remove(*i); return Ok(true); } @@ -156,21 +160,24 @@ impl Archive { /// # Example /// /// ``` - /// use hpk_package::tar::Archive; + /// use hpk::tar::Archive; /// let archive = Archive::new("test/1.txt").unwrap(); /// let node = archive.get("test/1.txt"); /// assert!(node.is_some()); /// ``` pub fn get(&self, filename: &str) -> Option { - self.nodes.par_iter().find_any(|x| { - x.header.file_path() == Ok(PathBuf::from(filename)) - }).cloned() + self.nodes + .par_iter() + .find_any(|x| x.header.file_path() == Ok(PathBuf::from(filename))) + .cloned() } pub fn pop(&mut self, filename: &str) -> Option { - if let Some(i) = self.nodes.par_iter().position_any(|x| { - x.header.file_path() == Ok(PathBuf::from(filename)) - }) { + if let Some(i) = self + .nodes + .par_iter() + .position_any(|x| x.header.file_path() == Ok(PathBuf::from(filename))) + { let node = self.nodes.get(i).cloned(); self.nodes.remove(i); return node; diff --git a/hpk-package/src/tar/node.rs b/src/tar/node.rs similarity index 97% rename from hpk-package/src/tar/node.rs rename to src/tar/node.rs index e618910..ba57019 100644 --- a/hpk-package/src/tar/node.rs +++ b/src/tar/node.rs @@ -34,7 +34,7 @@ impl Node { Ok(written) } - /// Read a TarNode in from a file or something with a ``std::io::Read`` trait. + /// Read a `Node` in from a file or something with a ``std::io::Read`` trait. pub fn read(mut input: T) -> Result { let mut h = vec![0u8; 512]; input.read_exact(&mut h)?; @@ -57,7 +57,7 @@ impl Node { }) } - /// Open and read a file from the ``filename`` argument to a TarNode. + /// Open and read a file from the ``filename`` argument to a `Node`. pub fn read_file_to_tar(filename: &str) -> Result { let header = Header::new(filename)?; if header.link_indicator[0] != FileType::Normal as u8 { diff --git a/hpk-package/src/version/gitrev.rs b/src/version/gitrev.rs similarity index 100% rename from hpk-package/src/version/gitrev.rs rename to src/version/gitrev.rs diff --git a/hpk-package/src/version/mod.rs b/src/version/mod.rs similarity index 96% rename from hpk-package/src/version/mod.rs rename to src/version/mod.rs index 903b117..6b74158 100644 --- a/hpk-package/src/version/mod.rs +++ b/src/version/mod.rs @@ -11,9 +11,9 @@ pub use {gitrev::GitRev, rapid::Rapid, semver::SemVer}; #[derive(Clone, Debug, Serialize, Deserialize)] /// An enum representing the most common versioning schemes. -/// Each scheme must implement Eq and Ord with itself, and -/// may optionally implement PartialEq and PartialOrd with -/// other schemes. Number, Rapid, and SemVer do this, while +/// Each scheme must implement `Eq` and `Ord` with itself, and +/// may optionally implement `PartialEq` and `PartialOrd` with +/// other schemes. `Number`, `Rapid`, and `SemVer` do this, while /// Git can only compare with itself. pub enum Version { /// A single replease number, as in Firefox 102 diff --git a/hpk-package/src/version/rapid.rs b/src/version/rapid.rs similarity index 89% rename from hpk-package/src/version/rapid.rs rename to src/version/rapid.rs index e7842fa..5c6f900 100644 --- a/hpk-package/src/version/rapid.rs +++ b/src/version/rapid.rs @@ -168,27 +168,47 @@ mod test { #[test] fn rapid_num_eq() { - let rapid = Rapid { major: 42, minor: 0 }; + let rapid = Rapid { + major: 42, + minor: 0, + }; assert_eq!(rapid, 42); } #[test] fn rapid_num_gt() { - let rapid = Rapid { major: 1, minor: 42 }; + let rapid = Rapid { + major: 1, + minor: 42, + }; assert!(rapid > 1); } #[test] fn rapid_semver_eq() { - let rapid = Rapid { major: 42, minor: 69 }; - let semver = SemVer { major: 42, minor: 69, patch: 0 }; + let rapid = Rapid { + major: 42, + minor: 69, + }; + let semver = SemVer { + major: 42, + minor: 69, + patch: 0, + }; assert_eq!(rapid, semver); } #[test] fn rapid_semver_lt() { - let rapid = Rapid { major: 42, minor: 69 }; - let semver = SemVer { major: 42, minor: 69, patch: 1 }; + let rapid = Rapid { + major: 42, + minor: 69, + }; + let semver = SemVer { + major: 42, + minor: 69, + patch: 1, + }; assert!(rapid < semver); } } diff --git a/hpk-package/src/version/semver.rs b/src/version/semver.rs similarity index 100% rename from hpk-package/src/version/semver.rs rename to src/version/semver.rs diff --git a/hpk-package/test/1.tar b/test/1.tar similarity index 100% rename from hpk-package/test/1.tar rename to test/1.tar diff --git a/hpk-package/test/1.txt b/test/1.txt similarity index 100% rename from hpk-package/test/1.txt rename to test/1.txt diff --git a/hpk-package/test/2.tar b/test/2.tar similarity index 98% rename from hpk-package/test/2.tar rename to test/2.tar index d37f5f88b97f1e407fb36b86a6fbcba352351702..7b754362d98bbee0c3361820a486b411811990c2 100644 GIT binary patch delta 49 zcmZn&Xb70lBWP}5U}$b=!eC%%U}9p-pkOdLkuim*w74X(NI`)iFR>(bqM*;_NXF%A E08iiz@&Et; delta 51 zcmZn&Xb70lBWP-9XkcJs#$aG*U~Xo_pkOdLkuim@w74X(NI`)iFR>&eF>j)v*XBsZ G