Struct git_repository::clone::Prepare
source · [−]pub struct Prepare { /* private fields */ }
Expand description
A utility to collect configuration on how to fetch from a remote and possibly create a working tree locally.
Implementations
sourceimpl Prepare
impl Prepare
Instantiation
sourcepub fn new<Url, E>(
url: Url,
path: impl AsRef<Path>,
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>,
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.
sourceimpl Prepare
impl Prepare
Modification
sourcepub fn fetch_only(
&mut self,
progress: impl Progress,
should_interrupt: &AtomicBool
) -> Result<(Repository, Outcome), Error>
Available on crate feature blocking-network-client
only.
pub fn fetch_only(
&mut self,
progress: impl Progress,
should_interrupt: &AtomicBool
) -> Result<(Repository, Outcome), Error>
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.
Note that all data we created will be removed once this instance drops if the operation wasn’t successful.
sourceimpl Prepare
impl Prepare
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<'_>, Error> + 'static
) -> Self
pub fn configure_remote(
self,
f: impl FnMut(Remote<'_>) -> Result<Remote<'_>, Error> + '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.
sourcepub fn with_remote_name(self, name: impl Into<String>) -> Result<Self, Error>
pub fn with_remote_name(self, name: impl Into<String>) -> 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
.
sourceimpl Prepare
impl Prepare
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 interacting with the remote or checking out the main working tree.