pub struct Repo { /* private fields */ }Expand description
Repository
Implementations§
source§impl Repo
impl Repo
sourcepub fn new(directory: impl AsRef<Utf8Path>) -> Result<Self>
pub fn new(directory: impl AsRef<Utf8Path>) -> Result<Self>
Returns an error if the directory doesn’t contain any commit
pub fn directory(&self) -> &Utf8Path
pub fn checkout_new_branch(&self, branch: &str) -> Result<()>
pub fn add_all_and_commit(&self, message: &str) -> Result<()>
sourcepub fn changes(&self, filter: impl FnMut(&&str) -> bool) -> Result<Vec<String>>
pub fn changes(&self, filter: impl FnMut(&&str) -> bool) -> Result<Vec<String>>
Get the list of changed files.
filter is applied for each line of git status --porcelain.
Only changes for which filter returns true are returned.
pub fn changes_except_typechanges(&self) -> Result<Vec<String>>
pub fn add<T: AsRef<str>>(&self, paths: &[T]) -> Result<()>
pub fn commit(&self, message: &str) -> Result<()>
pub fn commit_signed(&self, message: &str) -> Result<()>
pub fn push(&self, obj: &str) -> Result<()>
pub fn fetch(&self, obj: &str) -> Result<()>
pub fn force_push(&self, obj: &str) -> Result<()>
pub fn checkout_head(&self) -> Result<()>
sourcepub fn original_branch(&self) -> &str
pub fn original_branch(&self) -> &str
Branch name before running any git operation.
I.e. when the Repo was created.
sourcepub fn git(&self, args: &[&str]) -> Result<String>
pub fn git(&self, args: &[&str]) -> Result<String>
Run a git command in the repository git directory
pub fn stash_pop(&self) -> Result<()>
sourcepub fn checkout_last_commit_at_paths(&self, paths: &[&Path]) -> Result<()>
pub fn checkout_last_commit_at_paths(&self, paths: &[&Path]) -> Result<()>
Checkout to the latest commit.
pub fn checkout_previous_commit_at_paths(&self, paths: &[&Path]) -> Result<()>
pub fn checkout(&self, object: &str) -> Result<()>
pub fn current_commit_message(&self) -> Result<String>
sourcepub fn current_commit_hash(&self) -> Result<String>
pub fn current_commit_hash(&self) -> Result<String>
Get the SHA1 of the current HEAD.
sourcepub fn get_tag_commit(&self, tag: &str) -> Option<String>
pub fn get_tag_commit(&self, tag: &str) -> Option<String>
Get the commit hash of the given tag
sourcepub fn is_ancestor(
&self,
maybe_ancestor_commit: &str,
descendant_commit: &str
) -> bool
pub fn is_ancestor( &self, maybe_ancestor_commit: &str, descendant_commit: &str ) -> bool
Check if a commit comes before another one.
§Example
For this git log:
commit d6ec399b80d44bf9c4391e4a9ead8482faa9bffd
commit e880d8786cb16aa9a3f258e7503932445d708df7
git.is_ancestor("e880d8786cb16aa9a3f258e7503932445d708df7", "d6ec399b80d44bf9c4391e4a9ead8482faa9bffd") returns true.
sourcepub fn original_remote_url(&self) -> Result<String>
pub fn original_remote_url(&self) -> Result<String>
Url of the remote when the Repo was created.
pub fn tag_exists(&self, tag: &str) -> Result<bool>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Repo
impl RefUnwindSafe for Repo
impl Send for Repo
impl Sync for Repo
impl Unpin for Repo
impl UnwindSafe for Repo
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more