Struct git_workarea::GitContext
source · pub struct GitContext { /* private fields */ }
Expand description
A context for performing git commands.
Implementations§
source§impl GitContext
impl GitContext
sourcepub fn new<P>(gitdir: P) -> Selfwhere
P: Into<PathBuf>,
pub fn new<P>(gitdir: P) -> Selfwhere P: Into<PathBuf>,
Create a new context for the given directory.
sourcepub fn new_with_config<P, C>(gitdir: P, config: C) -> Selfwhere
P: Into<PathBuf>,
C: Into<PathBuf>,
pub fn new_with_config<P, C>(gitdir: P, config: C) -> Selfwhere P: Into<PathBuf>, C: Into<PathBuf>,
Create a new context for the given directory with git configuration.
sourcepub fn git(&self) -> Command
pub fn git(&self) -> Command
Run a git command in the context.
This builds a Command
with the proper environment to operate within the context.
sourcepub fn fetch<R, I, N>(&self, remote: R, refnames: I) -> Result<(), GitError>where
R: AsRef<str>,
I: IntoIterator<Item = N>,
N: AsRef<OsStr>,
pub fn fetch<R, I, N>(&self, remote: R, refnames: I) -> Result<(), GitError>where R: AsRef<str>, I: IntoIterator<Item = N>, N: AsRef<OsStr>,
Fetch references from the given remote.
The remote is interpreted by Git, so it can be a remote or a specific URL.
sourcepub fn fetch_into<R, N, T>(
&self,
remote: R,
refname: N,
target: T
) -> Result<(), GitError>where
R: AsRef<str>,
N: AsRef<str>,
T: AsRef<str>,
pub fn fetch_into<R, N, T>( &self, remote: R, refname: N, target: T ) -> Result<(), GitError>where R: AsRef<str>, N: AsRef<str>, T: AsRef<str>,
Fetch a commit from the given remote into a specific local refname.
sourcepub fn force_fetch_into<R, N, T>(
&self,
remote: R,
refname: N,
target: T
) -> Result<(), GitError>where
R: AsRef<str>,
N: AsRef<str>,
T: AsRef<str>,
pub fn force_fetch_into<R, N, T>( &self, remote: R, refname: N, target: T ) -> Result<(), GitError>where R: AsRef<str>, N: AsRef<str>, T: AsRef<str>,
Fetch a commit from the given remote into a specific local refname, allowing rewinds.
sourcepub fn default_branch(&self) -> Result<Option<String>, GitError>
pub fn default_branch(&self) -> Result<Option<String>, GitError>
Determine the “default branch” for the repository.
sourcepub fn prepare(&self, rev: &CommitId) -> Result<GitWorkArea, WorkAreaError>
pub fn prepare(&self, rev: &CommitId) -> Result<GitWorkArea, WorkAreaError>
Create a tree where further work on the given revision can occur.
sourcepub fn reserve_ref<N>(
&self,
name: N,
commit: &CommitId
) -> Result<(String, usize), GitError>where
N: AsRef<str>,
pub fn reserve_ref<N>( &self, name: N, commit: &CommitId ) -> Result<(String, usize), GitError>where N: AsRef<str>,
Reserve a refname for the given commit.
Returns the name of the reserved ref pointing to the given commit and its ID.
The reserved reference is created as refs/{name}/heads/{id}
where id
is a unique
integer (which is also returned).
sourcepub fn reserve_refs<N>(
&self,
name: N,
commit: &CommitId
) -> Result<(String, String), GitError>where
N: AsRef<str>,
pub fn reserve_refs<N>( &self, name: N, commit: &CommitId ) -> Result<(String, String), GitError>where N: AsRef<str>,
Reserve two refnames for the given commit.
Returns the names of the two reserved refs, the first pointing to the given commit and the second available for further work.
The reserved references are created as refs/{name}/heads/{id}
and
refs/{name}/bases/{id}
where the bases
reference is available to point to an object
associated with the heads
reference.
It is assumed that the bases
refs are aligned with the heads
references and not used
for other purposes.
Trait Implementations§
source§impl Clone for GitContext
impl Clone for GitContext
source§fn clone(&self) -> GitContext
fn clone(&self) -> GitContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more