Struct git_wrapper::Repository
source · [−]pub struct Repository { /* private fields */ }
Expand description
The main repository object.
This wrapper allows to keep track of optional git-dir and work-tree directories when
executing commands. This functionality was needed for glv
& git-stree
project.
Implementations
sourceimpl Repository
impl Repository
Getters
sourcepub fn is_shallow(&self) -> bool
pub fn is_shallow(&self) -> bool
Panics
Panics of executing git-rev-parse(1) fails
sourcepub fn work_tree(&self) -> Option<PathBuf>
pub fn work_tree(&self) -> Option<PathBuf>
Return path to git WORK_TREE
TODO move to generic repo trait TODO Remove optional
sourcepub fn short_ref(&self, long_ref: &str) -> Result<String, InvalidRefError>
pub fn short_ref(&self, long_ref: &str) -> Result<String, InvalidRefError>
Errors
Will return InvalidRefError
if invalid reference provided
sourceimpl Repository
impl Repository
Constructors
sourceimpl Repository
impl Repository
Functions
sourcepub fn commit(&self, message: &str) -> Result<(), CommitError>
pub fn commit(&self, message: &str) -> Result<(), CommitError>
Return config value for specified key
Errors
See CommitError
Panics
When git-commit(1)
fails to execute
sourcepub fn commit_extended(
&self,
message: &str,
allow_empty: bool,
no_verify: bool
) -> Result<(), CommitError>
pub fn commit_extended(
&self,
message: &str,
allow_empty: bool,
no_verify: bool
) -> Result<(), CommitError>
Errors
See CommitError
sourcepub fn hack_read_file(&self, path: &Path) -> Result<Vec<u8>>
pub fn hack_read_file(&self, path: &Path) -> Result<Vec<u8>>
Read file from workspace or use git-show(1)
if bare repository
Panics
When UTF-8 encoding path fails
Errors
When fails throws std::io::Error
TODO move to generic repo trait
sourcepub fn is_ancestor(&self, first: &str, second: &str) -> bool
pub fn is_ancestor(&self, first: &str, second: &str) -> bool
Returns true if the first
commit is an ancestor of the second
commit.
sourcepub fn remote_ref_to_id(
&self,
remote: &str,
git_ref: &str
) -> Result<String, RefSearchError>
pub fn remote_ref_to_id(
&self,
remote: &str,
git_ref: &str
) -> Result<String, RefSearchError>
Errors
See RefSearchError
sourcepub fn stash_almost_all(&self, message: &str) -> Result<(), StashingError>
pub fn stash_almost_all(&self, message: &str) -> Result<(), StashingError>
sourcepub fn stash_pop(&self) -> Result<(), StashingError>
pub fn stash_pop(&self) -> Result<(), StashingError>
sourcepub fn subtree_add(
&self,
url: &str,
prefix: &str,
revision: &str,
message: &str
) -> Result<(), SubtreeAddError>
pub fn subtree_add(
&self,
url: &str,
prefix: &str,
revision: &str,
message: &str
) -> Result<(), SubtreeAddError>
sourcepub fn subtree_split(&self, prefix: &str) -> Result<(), SubtreeSplitError>
pub fn subtree_split(&self, prefix: &str) -> Result<(), SubtreeSplitError>
sourcepub fn subtree_pull(
&self,
remote: &str,
prefix: &str,
git_ref: &str,
message: &str
) -> Result<(), SubtreePullError>
pub fn subtree_pull(
&self,
remote: &str,
prefix: &str,
git_ref: &str,
message: &str
) -> Result<(), SubtreePullError>
sourcepub fn subtree_push(
&self,
remote: &str,
prefix: &str,
git_ref: &str
) -> Result<(), SubtreePushError>
pub fn subtree_push(
&self,
remote: &str,
prefix: &str,
git_ref: &str
) -> Result<(), SubtreePushError>
Errors
Fails if current repo is bare. In other error cases see the provided message string.
sourceimpl Repository
impl Repository
Commit Functions
sourcepub fn merge_base(
&self,
ids: &[&str]
) -> Result<Option<String>, InvalidCommitishError>
pub fn merge_base(
&self,
ids: &[&str]
) -> Result<Option<String>, InvalidCommitishError>
Trait Implementations
sourceimpl Clone for Repository
impl Clone for Repository
sourcefn clone(&self) -> Repository
fn clone(&self) -> Repository
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more