pub mod git;
#[cfg(test)]
pub mod temp;
use crate::f_string::PythonFormatString;
use std::future::Future;
use std::path::{Path, PathBuf};
#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TagInfo {
pub dirty: bool,
pub commit_sha: String,
pub distance_to_latest_tag: usize,
pub current_tag: String,
pub current_version: String,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RevisionInfo {
pub branch_name: String,
pub short_branch_name: String,
pub repository_root: PathBuf,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TagAndRevision {
pub tag: Option<TagInfo>,
pub revision: Option<RevisionInfo>,
}
pub trait VersionControlSystem {
type Error: std::error::Error + Send + Sync + 'static;
fn open(path: impl Into<PathBuf>) -> Result<Self, Self::Error>
where
Self: Sized;
fn path(&self) -> &Path;
fn add<P>(
&self,
files: impl IntoIterator<Item = P>,
) -> impl Future<Output = Result<(), Self::Error>>
where
P: AsRef<std::ffi::OsStr>;
fn commit<A, E, AS, EK, EV>(
&self,
message: &str,
extra_args: A,
env: E,
) -> impl Future<Output = Result<(), Self::Error>>
where
A: IntoIterator<Item = AS>,
E: IntoIterator<Item = (EK, EV)>,
AS: AsRef<std::ffi::OsStr>,
EK: AsRef<std::ffi::OsStr>,
EV: AsRef<std::ffi::OsStr>;
fn tag(
&self,
name: &str,
message: Option<&str>,
sign: bool,
) -> impl Future<Output = Result<(), Self::Error>>;
fn tags(&self) -> impl Future<Output = Result<Vec<String>, Self::Error>>;
fn dirty_files(&self) -> impl Future<Output = Result<Vec<PathBuf>, Self::Error>>;
fn latest_tag_and_revision(
&self,
tag_name: &PythonFormatString,
parse_version_regex: ®ex::Regex,
) -> impl Future<Output = Result<TagAndRevision, Self::Error>>;
}