Struct git_meta::GitRepo[][src]

pub struct GitRepo {
    pub url: GitUrl,
    pub head: Option<GitCommitMeta>,
    pub credentials: Option<GitCredentials>,
    pub branch: Option<String>,
    pub path: Option<PathBuf>,
}

Use GitRepo::open() to read a repo on disk. GitRepo::new() if you need to clone the repo.

Clone a repo with .git_clone() or git_clone_shallow()

Fields

url: GitUrl

The remote url of the repo

head: Option<GitCommitMeta>

The current commit. This can be configured prior to clone with with_commit()

credentials: Option<GitCredentials>

The ssh key or user/pass needed to clone for private repo

branch: Option<String>

The name of the remote branch. This can be configured with a local branch name prior to clone with with_branch().

path: Option<PathBuf>

The location of the repo on disk

Implementations

impl GitRepo[src]

pub fn git_clone<P: AsRef<Path>>(&self, target: P) -> Result<GitRepo>[src]

pub fn git_clone_shallow<P: AsRef<Path>>(&self, target: P) -> Result<GitRepo>[src]

impl GitRepo[src]

pub fn get_remote_name(&self, r: &Repository) -> Result<String>[src]

Return the remote name from the given git2::Repository For example, the typical remote name: origin

pub fn get_remote_branch_head_refs(
    &self,
    branch_filter: Option<Vec<String>>
) -> Result<BranchHeads>
[src]

Return a HashMap<String, GitCommitMeta> for a branch containing the branch names and the latest commit of the branch. Providing a branch_filter` will only return branches based on patterns matching the start of the branch name.

pub fn is_commit_in_branch<'repo>(
    r: &'repo Repository,
    commit: &Commit<'_>,
    branch: &Branch<'_>
) -> bool
[src]

Returns a bool if a commit exists in the branch using the git2 crate

pub fn get_git2_branch<'repo>(
    r: &'repo Repository,
    local_branch: &Option<String>
) -> Result<Branch<'repo>>
[src]

Return the git2::Branch struct for a local repo (as opposed to a remote repo) If local_branch is not provided, we'll select the current active branch, based on HEAD

pub fn remote_url_from_repository<'repo>(r: &'repo Repository) -> Result<String>[src]

Return the remote url from the given Repository

pub fn git_remote_from_path(path: &Path) -> Result<String>[src]

Returns the remote url after opening and validating repo from the local path

pub fn git_remote_from_repo(local_repo: &Repository) -> Result<String>[src]

Returns the remote url from the git2::Repository struct

impl GitRepo[src]

pub fn open(
    path: PathBuf,
    branch: Option<String>,
    commit_id: Option<String>
) -> Result<GitRepo>
[src]

Returns a GitRepo after parsing metadata from a repo

  • If a local branch is not provided, current checked out branch will be used. The provided branch will be resolved to its remote branch name
  • If commit_id is not provided, the current commit (the HEAD of branch) will be used

pub fn with_path(mut self: Self, path: PathBuf) -> Self[src]

Set the location of GitRepo on the filesystem

pub fn with_branch<S: Into<String>>(mut self: Self, branch: S) -> Self[src]

Intended to be set with the remote name branch of GitRepo

pub fn with_commit(mut self: Self, commit: Option<Commit<'_>>) -> Self[src]

Set the GitCommitMeta from git2::Commit

pub fn with_credentials(mut self: Self, creds: Option<GitCredentials>) -> Self[src]

Set GitCredentials for private repos None indicates public repo

pub fn new<S: AsRef<str>>(url: S) -> Result<GitRepo>[src]

Create a new GitRepo with url Use along with with_* methods to set other fields of GitRepo Use GitRepoCloner if you need to clone the repo, and convert back with GitRepo.into()

pub fn to_repository(&self) -> Result<Repository, Error>[src]

Returns a git2::Repository from self.path

Trait Implementations

impl Clone for GitRepo[src]

impl Debug for GitRepo[src]

impl Default for GitRepo[src]

impl From<Repository> for GitRepo[src]

fn from(repo: Repository) -> Self[src]

Convert from git2::Repository to GitRepo.

impl PartialEq<GitRepo> for GitRepo[src]

impl StructuralPartialEq for GitRepo[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<D> OwoColorize for D

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.