git-next-core 0.14.1

core for git-next, the trunk-based development manager
Documentation
//
use crate::{newtype, webhook};

use derive_more::Display;
use serde::Serialize;

#[derive(
    Clone,
    Debug,
    Hash,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    derive_more::Constructor,
    derive_more::Display,
    Serialize,
)]
#[display("{}", sha)]
pub struct Commit {
    sha: Sha,
    message: Message,
}
impl Commit {
    #[must_use]
    pub const fn sha(&self) -> &Sha {
        &self.sha
    }
    #[must_use]
    pub const fn message(&self) -> &Message {
        &self.message
    }
}

impl From<webhook::Push> for Commit {
    fn from(value: webhook::Push) -> Self {
        Self::new(
            Sha::new(value.sha().to_owned()),
            Message::new(value.message().to_owned()),
        )
    }
}

newtype!(
    Sha,
    String,
    Display,
    Hash,
    PartialOrd,
    Ord,
    Serialize,
    "The unique SHA for a git commit."
);
newtype!(
    Message,
    String,
    Display,
    Hash,
    PartialOrd,
    Ord,
    Serialize,
    "The commit message for a git commit."
);

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Histories {
    pub main: Vec<Commit>,
    pub next: Vec<Commit>,
    pub dev: Vec<Commit>,
}

pub mod log {
    use crate::BranchName;

    pub type Result<T> = core::result::Result<T, Error>;

    #[derive(Debug, thiserror::Error)]
    pub enum Error {
        #[error("branch: {branch}, error: {error}")]
        Gix { branch: BranchName, error: String },

        #[error("lock")]
        Lock,
    }
}