Skip to content

Commit 620d275

Browse files
committed
fix: deprecate Remote::push_url*() in favor of Remote::with_push*().
1 parent 1d4a7f5 commit 620d275

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

gix/src/remote/build.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use crate::{bstr::BStr, remote, Remote};
22

33
/// Builder methods
44
impl Remote<'_> {
5-
/// Set the `url` to be used when fetching data from a remote.
5+
/// Override the `url` to be used when fetching data from a remote.
6+
///
7+
/// Note that this URL is typically set during instantiation with [`crate::Repository::remote_at()`].
68
pub fn with_url<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
79
where
810
Url: TryInto<gix_url::Url, Error = E>,
@@ -16,6 +18,8 @@ impl Remote<'_> {
1618

1719
/// Set the `url` to be used when fetching data from a remote, without applying rewrite rules in case these could be faulty,
1820
/// eliminating one failure mode.
21+
///
22+
/// Note that this URL is typically set during instantiation with [`crate::Repository::remote_at_without_url_rewrite()`].
1923
pub fn with_url_without_url_rewrite<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
2024
where
2125
Url: TryInto<gix_url::Url, Error = E>,
@@ -28,7 +32,17 @@ impl Remote<'_> {
2832
}
2933

3034
/// Set the `url` to be used when pushing data to a remote.
35+
#[deprecated = "Use `with_push_url()` instead"]
3136
pub fn push_url<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
37+
where
38+
Url: TryInto<gix_url::Url, Error = E>,
39+
gix_url::parse::Error: From<E>,
40+
{
41+
self.with_push_url(url)
42+
}
43+
44+
/// Set the `url` to be used when pushing data to a remote.
45+
pub fn with_push_url<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
3246
where
3347
Url: TryInto<gix_url::Url, Error = E>,
3448
gix_url::parse::Error: From<E>,
@@ -41,7 +55,18 @@ impl Remote<'_> {
4155

4256
/// Set the `url` to be used when pushing data to a remote, without applying rewrite rules in case these could be faulty,
4357
/// eliminating one failure mode.
58+
#[deprecated = "Use `with_push_url_without_rewrite()` instead"]
4459
pub fn push_url_without_url_rewrite<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
60+
where
61+
Url: TryInto<gix_url::Url, Error = E>,
62+
gix_url::parse::Error: From<E>,
63+
{
64+
self.with_push_url_without_url_rewrite(url)
65+
}
66+
67+
/// Set the `url` to be used when pushing data to a remote, without applying rewrite rules in case these could be faulty,
68+
/// eliminating one failure mode.
69+
pub fn with_push_url_without_url_rewrite<Url, E>(self, url: Url) -> Result<Self, remote::init::Error>
4570
where
4671
Url: TryInto<gix_url::Url, Error = E>,
4772
gix_url::parse::Error: From<E>,

gix/tests/gix/remote/save.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ mod save_as_to {
6363
let repo = basic_repo()?;
6464
let mut remote = repo
6565
.remote_at("https://example.com/path")?
66-
.push_url("https://ein.hub/path")?
66+
.with_push_url("https://ein.hub/path")?
6767
.with_fetch_tags(gix::remote::fetch::Tags::All)
6868
.with_refspecs(
6969
[

gix/tests/gix/repository/remote.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod remote_at {
1313
assert_eq!(remote.url(Direction::Fetch).unwrap().to_bstring(), fetch_url);
1414
assert_eq!(remote.url(Direction::Push).unwrap().to_bstring(), fetch_url);
1515

16-
let mut remote = remote.push_url("[email protected]:./relative")?;
16+
let mut remote = remote.with_push_url("[email protected]:./relative")?;
1717
assert_eq!(
1818
remote.url(Direction::Push).unwrap().to_bstring(),
1919
"[email protected]:./relative"
@@ -75,7 +75,7 @@ mod remote_at {
7575

7676
let remote = repo
7777
.remote_at("https://github.com/foobar/gitoxide".to_owned())?
78-
.push_url("file://dev/null".to_owned())?;
78+
.with_push_url("file://dev/null".to_owned())?;
7979
assert_eq!(remote.url(Direction::Fetch).unwrap().to_bstring(), rewritten_fetch_url);
8080
assert_eq!(
8181
remote.url(Direction::Push).unwrap().to_bstring(),
@@ -117,7 +117,7 @@ mod remote_at {
117117

118118
let remote = repo
119119
.remote_at_without_url_rewrite("https://github.com/foobar/gitoxide".to_owned())?
120-
.push_url_without_url_rewrite("file://dev/null".to_owned())?;
120+
.with_push_url_without_url_rewrite("file://dev/null".to_owned())?;
121121
assert_eq!(remote.url(Direction::Fetch).unwrap().to_bstring(), fetch_url);
122122
assert_eq!(
123123
remote.url(Direction::Push).unwrap().to_bstring(),
@@ -127,7 +127,7 @@ mod remote_at {
127127

128128
let remote = remote
129129
.with_url_without_url_rewrite("https://github.com/foobaz/gitoxide".to_owned())?
130-
.push_url_without_url_rewrite("file://dev/null".to_owned())?;
130+
.with_push_url_without_url_rewrite("file://dev/null".to_owned())?;
131131
assert_eq!(
132132
remote.url(Direction::Fetch).unwrap().to_bstring(),
133133
"https://github.com/foobaz/gitoxide"

0 commit comments

Comments
 (0)