Struct git_repository::clone::PrepareFetch
source · pub struct PrepareFetch { /* private fields */ }
Expand description
A utility to collect configuration on how to fetch from a remote and initiate a fetch operation. It will delete the newly created repository on when dropped without successfully finishing a fetch.
Implementations§
source§impl PrepareFetch
impl PrepareFetch
Modification
sourcepub fn fetch_only<P>(
&mut self,
progress: P,
should_interrupt: &AtomicBool
) -> Result<(Repository, Outcome), Error>where
P: Progress,
P::SubProgress: 'static,
Available on crate feature blocking-network-client
only.
pub fn fetch_only<P>( &mut self, progress: P, should_interrupt: &AtomicBool ) -> Result<(Repository, Outcome), Error>where P: Progress, P::SubProgress: 'static,
blocking-network-client
only.Fetch a pack and update local branches according to refspecs, providing progress
and checking should_interrupt
to stop
the operation.
On success, the persisted repository is returned, and this method must not be called again to avoid a panic.
On error, the method may be called again to retry as often as needed.
If the remote repository was empty, that is newly initialized, the returned repository will also be empty and like it was newly initialized.
Note that all data we created will be removed once this instance drops if the operation wasn’t successful.
sourcepub fn fetch_then_checkout<P>(
&mut self,
progress: P,
should_interrupt: &AtomicBool
) -> Result<(PrepareCheckout, Outcome), Error>where
P: Progress,
P::SubProgress: 'static,
Available on crate feature blocking-network-client
only.
pub fn fetch_then_checkout<P>( &mut self, progress: P, should_interrupt: &AtomicBool ) -> Result<(PrepareCheckout, Outcome), Error>where P: Progress, P::SubProgress: 'static,
blocking-network-client
only.Similar to fetch_only()
, but passes ownership to a utility type to configure a checkout operation.
source§impl PrepareFetch
impl PrepareFetch
Builder
sourcepub fn with_fetch_options(self, opts: Options) -> Self
Available on crate features async-network-client
or blocking-network-client
only.
pub fn with_fetch_options(self, opts: Options) -> Self
async-network-client
or blocking-network-client
only.Set additional options to adjust parts of the fetch operation that are not affected by the git configuration.
sourcepub fn configure_remote(
self,
f: impl FnMut(Remote<'_>) -> Result<Remote<'_>, Box<dyn Error + Send + Sync>> + 'static
) -> Self
pub fn configure_remote( self, f: impl FnMut(Remote<'_>) -> Result<Remote<'_>, Box<dyn Error + Send + Sync>> + 'static ) -> Self
Use f
to apply arbitrary changes to the remote that is about to be used to fetch a pack.
The passed in remote
will be un-named and pre-configured to be a default remote as we know it from git-clone.
It is not yet present in the configuration of the repository,
but each change it will eventually be written to the configuration prior to performing a the fetch operation,
all changes done in f()
will be persisted.
It can also be used to configure additional options, like those for fetching tags. Note that with_fetch_tags() should be called here to configure the clone as desired. Otherwise a clone is configured to be complete and fetches all tags, not only those reachable from all branches.
sourcepub fn with_remote_name(self, name: impl Into<BString>) -> Result<Self, Error>
pub fn with_remote_name(self, name: impl Into<BString>) -> Result<Self, Error>
Set the remote’s name to the given value after it was configured using the function provided via
configure_remote()
.
If not set here, it defaults to origin
or the value of clone.defaultRemoteName
.
source§impl PrepareFetch
impl PrepareFetch
Consumption
sourcepub fn persist(self) -> Repository
pub fn persist(self) -> Repository
Persist the contained repository as is even if an error may have occurred when fetching from the remote.
source§impl PrepareFetch
impl PrepareFetch
Instantiation
sourcepub fn new<Url, E>(
url: Url,
path: impl AsRef<Path>,
kind: Kind,
create_opts: Options,
open_opts: Options
) -> Result<Self, Error>where
Url: TryInto<Url, Error = E>,
Error: From<E>,
pub fn new<Url, E>( url: Url, path: impl AsRef<Path>, kind: Kind, create_opts: Options, open_opts: Options ) -> Result<Self, Error>where Url: TryInto<Url, Error = E>, Error: From<E>,
Create a new repository at path
with crate_opts
which is ready to clone from url
, possibly after making additional adjustments to
configuration and settings.
Note that this is merely a handle to perform the actual connection to the remote, and if any of it fails the freshly initialized repository will be removed automatically as soon as this instance drops.