1
1
mirror of https://github.com/Byron/gitoxide synced 2025-10-06 01:52:40 +02:00

fix: deprecate Remote::push_url*() in favor of Remote::with_push*().

This commit is contained in:
Sebastian Thiel
2025-09-17 04:46:21 +02:00
parent 1d4a7f534d
commit 620d275bea
3 changed files with 31 additions and 6 deletions

View File

@@ -2,7 +2,9 @@ use crate::{bstr::BStr, remote, Remote};
/// Builder methods
impl Remote<'_> {
/// Set the `url` to be used when fetching data from a remote.
/// Override the `url` to be used when fetching data from a remote.
///
/// Note that this URL is typically set during instantiation with [`crate::Repository::remote_at()`].
pub fn with_url<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
where
Url: TryInto<gix_url::Url, Error = E>,
@@ -16,6 +18,8 @@ impl Remote<'_> {
/// Set the `url` to be used when fetching data from a remote, without applying rewrite rules in case these could be faulty,
/// eliminating one failure mode.
///
/// Note that this URL is typically set during instantiation with [`crate::Repository::remote_at_without_url_rewrite()`].
pub fn with_url_without_url_rewrite<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
where
Url: TryInto<gix_url::Url, Error = E>,
@@ -28,7 +32,17 @@ impl Remote<'_> {
}
/// Set the `url` to be used when pushing data to a remote.
#[deprecated = "Use `with_push_url()` instead"]
pub fn push_url<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
where
Url: TryInto<gix_url::Url, Error = E>,
gix_url::parse::Error: From<E>,
{
self.with_push_url(url)
}
/// Set the `url` to be used when pushing data to a remote.
pub fn with_push_url<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
where
Url: TryInto<gix_url::Url, Error = E>,
gix_url::parse::Error: From<E>,
@@ -41,7 +55,18 @@ impl Remote<'_> {
/// 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.
#[deprecated = "Use `with_push_url_without_rewrite()` instead"]
pub fn push_url_without_url_rewrite<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
where
Url: TryInto<gix_url::Url, Error = E>,
gix_url::parse::Error: From<E>,
{
self.with_push_url_without_url_rewrite(url)
}
/// 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.
pub fn with_push_url_without_url_rewrite<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
where
Url: TryInto<gix_url::Url, Error = E>,
gix_url::parse::Error: From<E>,

View File

@@ -63,7 +63,7 @@ mod save_as_to {
let repo = basic_repo()?;
let mut remote = repo
.remote_at("https://example.com/path")?
.push_url("https://ein.hub/path")?
.with_push_url("https://ein.hub/path")?
.with_fetch_tags(gix::remote::fetch::Tags::All)
.with_refspecs(
[

View File

@@ -13,7 +13,7 @@ mod remote_at {
assert_eq!(remote.url(Direction::Fetch).unwrap().to_bstring(), fetch_url);
assert_eq!(remote.url(Direction::Push).unwrap().to_bstring(), fetch_url);
let mut remote = remote.push_url("user@host.xz:./relative")?;
let mut remote = remote.with_push_url("user@host.xz:./relative")?;
assert_eq!(
remote.url(Direction::Push).unwrap().to_bstring(),
"user@host.xz:./relative"
@@ -75,7 +75,7 @@ mod remote_at {
let remote = repo
.remote_at("https://github.com/foobar/gitoxide".to_owned())?
.push_url("file://dev/null".to_owned())?;
.with_push_url("file://dev/null".to_owned())?;
assert_eq!(remote.url(Direction::Fetch).unwrap().to_bstring(), rewritten_fetch_url);
assert_eq!(
remote.url(Direction::Push).unwrap().to_bstring(),
@@ -117,7 +117,7 @@ mod remote_at {
let remote = repo
.remote_at_without_url_rewrite("https://github.com/foobar/gitoxide".to_owned())?
.push_url_without_url_rewrite("file://dev/null".to_owned())?;
.with_push_url_without_url_rewrite("file://dev/null".to_owned())?;
assert_eq!(remote.url(Direction::Fetch).unwrap().to_bstring(), fetch_url);
assert_eq!(
remote.url(Direction::Push).unwrap().to_bstring(),
@@ -127,7 +127,7 @@ mod remote_at {
let remote = remote
.with_url_without_url_rewrite("https://github.com/foobaz/gitoxide".to_owned())?
.push_url_without_url_rewrite("file://dev/null".to_owned())?;
.with_push_url_without_url_rewrite("file://dev/null".to_owned())?;
assert_eq!(
remote.url(Direction::Fetch).unwrap().to_bstring(),
"https://github.com/foobaz/gitoxide"