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

pub fn list_files_changed<S: AsRef<str>>(
    &self,
    commit1: S,
    commit2: S
) -> Result<Option<Vec<PathBuf>>>
[src]

Returns a Result<Option<Vec<PathBuf>>> containing files changed between commit1 and commit2

pub fn expand_partial_commit_id<S: AsRef<str>>(
    &self,
    partial_commit_id: S
) -> Result<String>
[src]

Takes in a partial commit SHA-1, and attempts to expand to the full 40-char commit id

pub fn has_path_changed<P: AsRef<Path>>(&self, path: P) -> bool[src]

Checks the list of files changed between last 2 commits (HEAD and HEAD~1). Returns bool depending on whether any changes were made in path. A path should be relative to the repo root. Can be a file or a directory.

pub fn has_path_changed_between<P: AsRef<Path>, S: AsRef<str>>(
    &self,
    path: P,
    commit1: S,
    commit2: S
) -> bool
[src]

Checks the list of files changed between 2 commits (commit1 and commit2). Returns bool depending on whether any changes were made in path. A path should be relative to the repo root. Can be a file or a directory.

pub fn new_commits_exist(&self) -> bool[src]

Check if new commits exist by performing a shallow clone and comparing branch heads

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(self, path: PathBuf) -> Self[src]

Set the location of GitRepo on the filesystem

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

Intended to be set with the remote name branch of GitRepo

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

Set the GitCommitMeta from git2::Commit

pub fn with_credentials(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

pub fn is_shallow(&self) -> bool[src]

Test whether GitRepo is a shallow clone

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.