[][src]Struct git2::build::RepoBuilder

pub struct RepoBuilder<'cb> { /* fields omitted */ }

A builder struct which is used to build configuration for cloning a new git repository.

Example

Cloning using SSH:

use git2::{Cred, Error, RemoteCallbacks};
use std::env;
use std::path::Path;

  // Prepare callbacks.
  let mut callbacks = RemoteCallbacks::new();
  callbacks.credentials(|_url, username_from_url, _allowed_types| {
    Cred::ssh_key(
      username_from_url.unwrap(),
      None,
      std::path::Path::new(&format!("{}/.ssh/id_rsa", env::var("HOME").unwrap())),
      None,
    )
  });

  // Prepare fetch options.
  let mut fo = git2::FetchOptions::new();
  fo.remote_callbacks(callbacks);

  // Prepare builder.
  let mut builder = git2::build::RepoBuilder::new();
  builder.fetch_options(fo);

  // Clone the project.
  builder.clone(
    "git@github.com:rust-lang/git2-rs.git",
    Path::new("/tmp/git2-rs"),
  );

Methods

impl<'cb> RepoBuilder<'cb>[src]

pub fn new() -> RepoBuilder<'cb>[src]

Creates a new repository builder with all of the default configuration.

When ready, the clone() method can be used to clone a new repository using this configuration.

pub fn bare(&mut self, bare: bool) -> &mut RepoBuilder<'cb>[src]

Indicate whether the repository will be cloned as a bare repository or not.

pub fn branch(&mut self, branch: &str) -> &mut RepoBuilder<'cb>[src]

Specify the name of the branch to check out after the clone.

If not specified, the remote's default branch will be used.

pub fn clone_local(&mut self, clone_local: CloneLocal) -> &mut RepoBuilder<'cb>[src]

Configures options for bypassing the git-aware transport on clone.

Bypassing it means that instead of a fetch libgit2 will copy the object database directory instead of figuring out what it needs, which is faster. If possible, it will hardlink the files to save space.

pub fn with_checkout(
    &mut self,
    checkout: CheckoutBuilder<'cb>
) -> &mut RepoBuilder<'cb>
[src]

Configure the checkout which will be performed by consuming a checkout builder.

pub fn fetch_options(
    &mut self,
    fetch_opts: FetchOptions<'cb>
) -> &mut RepoBuilder<'cb>
[src]

Options which control the fetch, including callbacks.

The callbacks are used for reporting fetch progress, and for acquiring credentials in the event they are needed.

pub fn remote_create<F>(&mut self, f: F) -> &mut RepoBuilder<'cb> where
    F: for<'a> FnMut(&'a Repository, &str, &str) -> Result<Remote<'a>, Error> + 'cb, 
[src]

Configures a callback used to create the git remote, prior to its being used to perform the clone operation.

pub fn clone(&mut self, url: &str, into: &Path) -> Result<Repository, Error>[src]

Clone a remote repository.

This will use the options configured so far to clone the specified url into the specified local path.

Trait Implementations

impl<'cb> Default for RepoBuilder<'cb>[src]

Auto Trait Implementations

impl<'cb> !RefUnwindSafe for RepoBuilder<'cb>

impl<'cb> !Send for RepoBuilder<'cb>

impl<'cb> !Sync for RepoBuilder<'cb>

impl<'cb> Unpin for RepoBuilder<'cb>

impl<'cb> !UnwindSafe for RepoBuilder<'cb>

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, U> Into<U> for T where
    U: From<T>, 
[src]

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.