From c8446051216b50a330611a8ba320aa17b8e81dcb Mon Sep 17 00:00:00 2001 From: Han Xu Date: Thu, 16 Feb 2023 04:33:13 -0800 Subject: [PATCH] radicle-git-ext: merge in git-commit Removed `mod references` and its uses in `radicle-macros` and `radicle-git-types` crates. Signed-off-by: Han Xu --- Cargo.toml | 2 - git-storage/src/glob.rs | 7 - git-storage/t/Cargo.toml | 2 +- radicle-git-ext/src/author.rs | 129 +++++ radicle-git-ext/src/commit.rs | 294 ++++++++++++ radicle-git-ext/src/commit/headers.rs | 71 +++ radicle-git-ext/src/commit/trailers.rs | 214 +++++++++ radicle-git-ext/src/lib.rs | 4 +- radicle-git-ext/src/reference.rs | 26 - radicle-git-ext/src/reference/iter.rs | 87 ---- radicle-git-ext/src/reference/name.rs | 637 ------------------------- radicle-git-ext/t/Cargo.toml | 2 +- radicle-git-ext/t/src/commit.rs | 176 +++++++ radicle-git-ext/t/src/lib.rs | 6 +- radicle-git-ext/t/src/tests.rs | 228 --------- radicle-git-types/Cargo.toml | 39 -- radicle-git-types/src/lib.rs | 79 --- radicle-git-types/src/reference.rs | 550 --------------------- radicle-git-types/src/refspec.rs | 201 -------- radicle-git-types/src/remote.rs | 203 -------- radicle-git-types/src/sealed.rs | 8 - radicle-macros/Cargo.toml | 20 - radicle-macros/src/lib.rs | 72 --- test/Cargo.toml | 2 +- 24 files changed, 890 insertions(+), 2169 deletions(-) create mode 100644 radicle-git-ext/src/author.rs create mode 100644 radicle-git-ext/src/commit.rs create mode 100644 radicle-git-ext/src/commit/headers.rs create mode 100644 radicle-git-ext/src/commit/trailers.rs delete mode 100644 radicle-git-ext/src/reference.rs delete mode 100644 radicle-git-ext/src/reference/iter.rs delete mode 100644 radicle-git-ext/src/reference/name.rs create mode 100644 radicle-git-ext/t/src/commit.rs delete mode 100644 radicle-git-ext/t/src/tests.rs delete mode 100644 radicle-git-types/Cargo.toml delete mode 100644 radicle-git-types/src/lib.rs delete mode 100644 radicle-git-types/src/reference.rs delete mode 100644 radicle-git-types/src/refspec.rs delete mode 100644 radicle-git-types/src/remote.rs delete mode 100644 radicle-git-types/src/sealed.rs delete mode 100644 radicle-macros/Cargo.toml delete mode 100644 radicle-macros/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 0ca20c1..bf87dcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,6 @@ members = [ "git-trailers", "link-git", "radicle-git-ext", - "radicle-git-types", - "radicle-macros", "radicle-std-ext", "radicle-surf", # TODO: port gitd-lib over diff --git a/git-storage/src/glob.rs b/git-storage/src/glob.rs index 8989417..b58fcc5 100644 --- a/git-storage/src/glob.rs +++ b/git-storage/src/glob.rs @@ -5,7 +5,6 @@ use std::path::Path; -use git_ext as ext; use git_ref_format::refspec::PatternString; pub trait Pattern { @@ -27,12 +26,6 @@ impl Pattern for globset::GlobSet { #[derive(Clone, Debug)] pub struct RefspecMatcher(globset::GlobMatcher); -impl From for RefspecMatcher { - fn from(pat: ext::RefspecPattern) -> Self { - Self(globset::Glob::new(pat.as_str()).unwrap().compile_matcher()) - } -} - impl From for RefspecMatcher { fn from(pat: PatternString) -> Self { Self(globset::Glob::new(pat.as_str()).unwrap().compile_matcher()) diff --git a/git-storage/t/Cargo.toml b/git-storage/t/Cargo.toml index 134b6c0..1ac59fb 100644 --- a/git-storage/t/Cargo.toml +++ b/git-storage/t/Cargo.toml @@ -35,7 +35,7 @@ path = "../../test/test-helpers" version = "1" features = ["v4"] -[dev-dependencies.git-ext-test] +[dev-dependencies.radicle-git-ext-test] path = "../../radicle-git-ext/t" features = ["test"] diff --git a/radicle-git-ext/src/author.rs b/radicle-git-ext/src/author.rs new file mode 100644 index 0000000..34a5d62 --- /dev/null +++ b/radicle-git-ext/src/author.rs @@ -0,0 +1,129 @@ +use std::{ + fmt, + num::ParseIntError, + str::{self, FromStr}, +}; + +use thiserror::Error; + +/// The data for indicating authorship of an action within a +/// [`crate::commit::Commit`]. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct Author { + /// Name corresponding to `user.name` in the git config. + /// + /// Note: this must not contain `<` or `>`. + pub name: String, + /// Email corresponding to `user.email` in the git config. + /// + /// Note: this must not contain `<` or `>`. + pub email: String, + /// The time of this author's action. + pub time: Time, +} + +/// The time of a [`Author`]'s action. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub struct Time { + seconds: i64, + offset: i32, +} + +impl Time { + pub fn new(seconds: i64, offset: i32) -> Self { + Self { seconds, offset } + } + + /// Return the time, in seconds, since the epoch. + pub fn seconds(&self) -> i64 { + self.seconds + } + + /// Return the timezone offset, in minutes. + pub fn offset(&self) -> i32 { + self.offset + } +} + +impl From