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 delete_branch_in_remote(&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.
Sourcepub fn files_of_current_commit(&self) -> Result<HashSet<Utf8PathBuf>>
pub fn files_of_current_commit(&self) -> Result<HashSet<Utf8PathBuf>>
Get files changed in the current commit
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<()>
Sourcepub fn add_worktree(&self, path: impl AsRef<str>, object: &str) -> Result<()>
pub fn add_worktree(&self, path: impl AsRef<str>, object: &str) -> Result<()>
Adds a detached git worktree at the given path checked out at the given object.
Sourcepub fn remove_worktree(&self, path: impl AsRef<str>) -> Result<()>
pub fn remove_worktree(&self, path: impl AsRef<str>) -> Result<()>
Removes a worktree that was created for this repository at the given path.
pub fn current_commit_message(&self) -> Result<String>
pub fn get_committer_name(&self, commit_hash: &str) -> Result<String>
pub fn get_committer_email(&self, commit_hash: &str) -> 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
Returns all the tags in the repository in an unspecified order.
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(&self) -> &str
pub fn original_remote(&self) -> &str
Name of the remote when the Repo
was created.
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.