#![doc = include_str!("../README.md")]
#[doc(hidden)]
#[macro_export]
macro_rules! flag_methods {
(
$(#[$attr:meta])*
$vis:vis fn $name:ident / $name_if:ident, $field:ident, $doc_if:literal
) => {
$(#[$attr])*
#[must_use]
$vis fn $name(self) -> Self {
self.$name_if(true)
}
#[doc = $doc_if]
#[must_use]
$vis fn $name_if(mut self, value: bool) -> Self {
self.$field = value;
self
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! impl_repo_path {
($ty:ident) => {
impl<'a> $ty<'a> {
#[must_use]
pub fn repo_path(mut self, path: &'a std::path::Path) -> Self {
self.repo_path = Some(path);
self
}
}
impl<'a> $crate::RepoPath<'a> for $ty<'a> {
fn repo_path(self, path: &'a std::path::Path) -> Self {
self.repo_path(path)
}
}
};
}
pub mod add;
pub mod branch;
pub mod clone;
pub mod commit;
pub mod config;
pub mod diff;
pub mod fetch;
pub mod init;
pub mod ls_remote;
pub mod push;
pub mod remote;
pub mod repository;
pub mod rev_list;
pub mod rev_parse;
pub mod show;
pub mod show_ref;
pub mod status;
pub mod worktree;
use std::path::Path;
pub use cmd_proc::CommandError;
pub trait Porcelain: Sized {
fn porcelain_if(self, value: bool) -> Self;
fn porcelain(self) -> Self {
self.porcelain_if(true)
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! impl_porcelain {
($ty:ident) => {
impl<'a> $ty<'a> {
#[must_use]
pub fn porcelain(self) -> Self {
self.porcelain_if(true)
}
#[must_use]
pub fn porcelain_if(mut self, value: bool) -> Self {
self.porcelain = value;
self
}
}
impl<'a> $crate::Porcelain for $ty<'a> {
fn porcelain_if(self, value: bool) -> Self {
self.porcelain_if(value)
}
}
};
}
#[must_use = "repo_path returns a modified builder; the return value must be used"]
pub trait RepoPath<'a>: Sized {
fn repo_path(self, path: &'a Path) -> Self;
}
pub trait Build {
fn build(self) -> cmd_proc::Command;
}
fn base_command(repo_path: Option<&Path>) -> cmd_proc::Command {
cmd_proc::Command::new("git").optional_option("-C", repo_path)
}