pub struct Remote<'repo> { /* private fields */ }
Expand description
A remote which represents a way to interact with hosts for remote clones of the parent repository.
Implementations§
source§impl Remote<'_>
impl Remote<'_>
Builder methods
sourcepub fn push_url<Url, E>(self, url: Url) -> Result<Self, Error>where
Url: TryInto<Url, Error = E>,
Error: From<E>,
pub fn push_url<Url, E>(self, url: Url) -> Result<Self, Error>where Url: TryInto<Url, Error = E>, Error: From<E>,
Set the url
to be used when pushing data to a remote.
sourcepub fn push_url_without_url_rewrite<Url, E>(
self,
url: Url
) -> Result<Self, Error>where
Url: TryInto<Url, Error = E>,
Error: From<E>,
pub fn push_url_without_url_rewrite<Url, E>( self, url: Url ) -> Result<Self, Error>where Url: TryInto<Url, Error = E>, Error: From<E>,
Set the url
to be used when pushing data to a remote, without applying rewrite rules in case these could be faulty,
eliminating one failure mode.
Configure how tags should be handled when fetching from the remote.
sourcepub fn with_refspecs<Spec>(
self,
specs: impl IntoIterator<Item = Spec>,
direction: Direction
) -> Result<Self, Error>where
Spec: AsRef<BStr>,
pub fn with_refspecs<Spec>( self, specs: impl IntoIterator<Item = Spec>, direction: Direction ) -> Result<Self, Error>where Spec: AsRef<BStr>,
Add specs
as refspecs for direction
to our list if they are unique, or ignore them otherwise.
source§impl<'repo> Remote<'repo>
impl<'repo> Remote<'repo>
Establishing connections to remote hosts (without performing a git-handshake).
sourcepub fn to_connection_with_transport<T>(
&self,
transport: T
) -> Connection<'_, 'repo, T>where
T: Transport,
Available on crate features async-network-client
or blocking-network-client
only.
pub fn to_connection_with_transport<T>( &self, transport: T ) -> Connection<'_, 'repo, T>where T: Transport,
async-network-client
or blocking-network-client
only.Create a new connection using transport
to communicate, with progress
to indicate changes.
Note that this method expects the transport
to be created by the user, which would involve the url()
.
It’s meant to be used when async operation is needed with runtimes of the user’s choice.
sourcepub fn connect(
&self,
direction: Direction
) -> Result<Connection<'_, 'repo, Box<dyn Transport + Send>>, Error>
Available on (crate features async-network-client
or blocking-network-client
) and (crate features blocking-network-client
or async-network-client-async-std
) only.
pub fn connect( &self, direction: Direction ) -> Result<Connection<'_, 'repo, Box<dyn Transport + Send>>, Error>
async-network-client
or blocking-network-client
) and (crate features blocking-network-client
or async-network-client-async-std
) only.Connect to the url suitable for direction
and return a handle through which operations can be performed.
Note that the protocol.version
configuration key affects the transport protocol used to connect,
with 2
being the default.
The transport used for connection can be configured via transport_mut().configure()
assuming the actually
used transport is well known. If that’s not the case, the transport can be created by hand and passed to
to_connection_with_transport().
sourcepub fn sanitized_url_and_version(
&self,
direction: Direction
) -> Result<(Url, Protocol), Error>
Available on crate features async-network-client
or blocking-network-client
only.
pub fn sanitized_url_and_version( &self, direction: Direction ) -> Result<(Url, Protocol), Error>
async-network-client
or blocking-network-client
only.Produce the sanitized URL and protocol version to use as obtained by querying the repository configuration.
This can be useful when using custom transports to allow additional configuration.
source§impl Remote<'_>
impl Remote<'_>
Serialize into git-config.
sourcepub fn save_to(&self, config: &mut File<'static>) -> Result<(), Error>
pub fn save_to(&self, config: &mut File<'static>) -> Result<(), Error>
Save ourselves to the given config
if we are a named remote or fail otherwise.
Note that all sections named remote "<name>"
will be cleared of all values we are about to write,
and the last remote "<name>"
section will be containing all relevant values so that reloading the remote
from config
would yield the same in-memory state.
sourcepub fn save_as_to(
&mut self,
name: impl Into<BString>,
config: &mut File<'static>
) -> Result<(), AsError>
pub fn save_as_to( &mut self, name: impl Into<BString>, config: &mut File<'static> ) -> Result<(), AsError>
Forcefully set our name to name
and write our state to config
similar to save_to()
.
Note that this sets a name for anonymous remotes, but overwrites the name for those who were named before. If this name is different from the current one, the git configuration will still contain the previous name, and the caller should account for that.
source§impl<'repo> Remote<'repo>
impl<'repo> Remote<'repo>
Access
sourcepub fn name(&self) -> Option<&Name<'static>>
pub fn name(&self) -> Option<&Name<'static>>
Return the name of this remote or None
if it wasn’t persisted to disk yet.
sourcepub fn repo(&self) -> &'repo Repository
pub fn repo(&self) -> &'repo Repository
Return our repository reference.
sourcepub fn refspecs(&self, direction: Direction) -> &[RefSpec]
pub fn refspecs(&self, direction: Direction) -> &[RefSpec]
Return the set of ref-specs used for direction
, which may be empty, in order of occurrence in the configuration.
Return how we handle tags when fetching the remote.
sourcepub fn url(&self, direction: Direction) -> Option<&Url>
pub fn url(&self, direction: Direction) -> Option<&Url>
Return the url used for the given direction
with rewrites from url.<base>.insteadOf|pushInsteadOf
, unless the instance
was created with one of the _without_url_rewrite()
methods.
For pushing, this is the remote.<name>.pushUrl
or the remote.<name>.url
used for fetching, and for fetching it’s
the remote.<name>.url
.
Note that it’s possible to only have the push url set, in which case there will be no way to fetch from the remote as
the push-url isn’t used for that.
source§impl Remote<'_>
impl Remote<'_>
Modification
sourcepub fn rewrite_urls(&mut self) -> Result<&mut Self, Error>
pub fn rewrite_urls(&mut self) -> Result<&mut Self, Error>
Read url.<base>.insteadOf|pushInsteadOf
configuration variables and apply them to our urls, changing them in place.
This happens only once, and one if them may be changed even when reporting an error. If both urls fail, only the first error (for fetch urls) is reported.
sourcepub fn replace_refspecs<Spec>(
&mut self,
specs: impl IntoIterator<Item = Spec>,
direction: Direction
) -> Result<(), Error>where
Spec: AsRef<BStr>,
pub fn replace_refspecs<Spec>( &mut self, specs: impl IntoIterator<Item = Spec>, direction: Direction ) -> Result<(), Error>where Spec: AsRef<BStr>,
Replace all currently set refspecs, typically from configuration, with the given specs
for direction
,
or None
if one of the input specs could not be parsed.