Struct GitContext

Source
pub struct GitContext { /* private fields */ }
Expand description

A context for performing git commands.

Implementations§

Source§

impl GitContext

Source

pub fn new<P>(gitdir: P) -> Self
where P: Into<PathBuf>,

Create a new context for the given directory.

Source

pub fn new_with_config<P, C>(gitdir: P, config: C) -> Self
where P: Into<PathBuf>, C: Into<PathBuf>,

Create a new context for the given directory with git configuration.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn default_branch(&self) -> Result<Option<String>, GitError>

Determine the “default branch” for the repository.

Source

pub fn prepare(&self, rev: &CommitId) -> Result<GitWorkArea, WorkAreaError>

Create a tree where further work on the given revision can occur.

Source

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).

Source

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.

Source

pub fn mergeable( &self, base: &CommitId, topic: &CommitId, ) -> Result<MergeStatus, GitError>

Check if a topic commit is mergeable into a target branch.

Source

pub fn gitdir(&self) -> &Path

The path to the git repository.

Trait Implementations§

Source§

impl Clone for GitContext

Source§

fn clone(&self) -> GitContext

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GitContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.