Skip to main content

Repository

Struct Repository 

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

A handle to a git working tree.

Construction does not spawn git. Repository::open only verifies that a .git directory (or file, for worktrees/submodules) exists at the path.

Implementations§

Source§

impl Repository

Source

pub fn open(path: impl Into<PathBuf>) -> Result<Self>

Open an existing repository at path without running git.

Returns Error::NotARepository if path/.git does not exist.

Source

pub fn new_unchecked(path: impl Into<PathBuf>) -> Self

Construct a Repository for path without checking that it exists.

Use this when you are about to run init or clone into the path.

Source

pub fn path(&self) -> &Path

Working-tree path.

Source

pub fn git_dir(&self) -> PathBuf

Path to the .git directory (or file) inside the working tree.

Source

pub async fn init(path: impl Into<PathBuf>) -> Result<Self>

Initialize a new repository at path.

Equivalent to git init <path>. Returns the created Repository.

Source

pub async fn clone( url: impl Into<String>, path: impl Into<PathBuf>, ) -> Result<Self>

Clone url into path.

Source

pub fn add(&self) -> AddCommand

Build an AddCommand scoped to this repository.

Source

pub fn commit(&self) -> CommitCommand

Build a CommitCommand scoped to this repository.

Source

pub fn status(&self) -> StatusCommand

Build a StatusCommand scoped to this repository.

Source

pub fn log(&self) -> LogCommand

Build a LogCommand scoped to this repository.

Source

pub fn diff(&self) -> DiffCommand

Build a DiffCommand scoped to this repository.

Source

pub fn show(&self) -> ShowCommand

Build a ShowCommand scoped to this repository.

Source

pub fn branch(&self) -> BranchCommand

Build a BranchCommand scoped to this repository.

Source

pub fn checkout(&self) -> CheckoutCommand

Build a CheckoutCommand scoped to this repository.

Source

pub fn switch(&self) -> SwitchCommand

Build a SwitchCommand scoped to this repository.

Source

pub fn merge(&self) -> MergeCommand

Build a MergeCommand scoped to this repository.

Source

pub fn rebase(&self) -> RebaseCommand

Build a RebaseCommand scoped to this repository.

Source

pub fn pull(&self) -> PullCommand

Build a PullCommand scoped to this repository.

Source

pub fn push(&self) -> PushCommand

Build a PushCommand scoped to this repository.

Source

pub fn fetch(&self) -> FetchCommand

Build a FetchCommand scoped to this repository.

Source

pub fn remote(&self, action: RemoteCommand) -> RemoteCommand

Build a RemoteCommand scoped to this repository.

Source

pub fn tag(&self) -> TagCommand

Build a TagCommand scoped to this repository.

Source

pub fn stash(&self, action: StashCommand) -> StashCommand

Build a StashCommand scoped to this repository.

Source

pub fn reset(&self) -> ResetCommand

Build a ResetCommand scoped to this repository.

Source

pub fn restore(&self) -> RestoreCommand

Build a RestoreCommand scoped to this repository.

Source

pub fn rm(&self) -> RmCommand

Build an RmCommand scoped to this repository.

Source

pub fn mv(&self, src: impl Into<String>, dst: impl Into<String>) -> MvCommand

Build an MvCommand scoped to this repository.

Source

pub fn cherry_pick(&self) -> CherryPickCommand

Build a CherryPickCommand scoped to this repository.

Source

pub fn grep(&self, pattern: impl Into<String>) -> GrepCommand

Build a GrepCommand scoped to this repository with the given pattern.

Source

pub fn config(&self, action: ConfigCommand) -> ConfigCommand

Build a ConfigCommand scoped to this repository.

Source

pub fn reflog(&self, action: ReflogCommand) -> ReflogCommand

Build a ReflogCommand scoped to this repository.

Source

pub fn worktree(&self, action: WorktreeCommand) -> WorktreeCommand

Build a WorktreeCommand scoped to this repository.

Source

pub fn submodule(&self, action: SubmoduleCommand) -> SubmoduleCommand

Build a SubmoduleCommand scoped to this repository.

Source

pub fn bisect(&self, action: BisectCommand) -> BisectCommand

Build a BisectCommand scoped to this repository.

Source§

impl Repository

Source

pub fn branches(&self) -> BranchOps<'_>

Available on crate feature workflow only.

Operations on local branches.

Source§

impl Repository

Source

pub fn history(&self) -> HistoryWalk<'_>

Available on crate feature workflow only.

Walk commit history with a chained-builder filter.

Source§

impl Repository

Source

pub async fn info(&self) -> Result<RepoInfo>

Available on crate feature workflow only.

Collect a RepoInfo snapshot in a single call.

Runs git status --porcelain=v2 --branch plus one symbolic-ref lookup for the default branch. See the module docs for details and caveats.

Source§

impl Repository

Source

pub fn tags(&self) -> TagOps<'_>

Available on crate feature workflow only.

Operations on tags.

Source§

impl Repository

Source

pub fn workflow(&self) -> WorkflowOps<'_>

Available on crate feature workflow only.

High-level workflow compositions.

Trait Implementations§

Source§

impl Clone for Repository

Source§

fn clone(&self) -> Repository

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Repository

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more