@@ -20,6 +20,10 @@ mod remote_at {
2020 ) ;
2121 assert_eq ! ( remote. url( Direction :: Fetch ) . unwrap( ) . to_bstring( ) , fetch_url) ;
2222
23+ let new_fetch_url = "https://host.xz/byron/gitoxide" ;
24+ remote = remote. with_url ( new_fetch_url) ?;
25+ assert_eq ! ( remote. url( Direction :: Fetch ) . unwrap( ) . to_bstring( ) , new_fetch_url) ;
26+
2327 for ( spec, direction) in [
2428 ( "refs/heads/push" , Direction :: Push ) ,
2529 ( "refs/heads/fetch" , Direction :: Fetch ) ,
@@ -57,6 +61,18 @@ mod remote_at {
5761 "push is the same as fetch was rewritten"
5862 ) ;
5963
64+ let remote = remote. with_url ( "https://github.com/foobar/gitoxide" ) ?;
65+ assert_eq ! (
66+ remote. url( Direction :: Fetch ) . unwrap( ) . to_bstring( ) ,
67+ rewritten_fetch_url,
68+ "fetch was rewritten"
69+ ) ;
70+ assert_eq ! (
71+ remote. url( Direction :: Push ) . unwrap( ) . to_bstring( ) ,
72+ rewritten_fetch_url,
73+ "push is the same as fetch was rewritten"
74+ ) ;
75+
6076 let remote = repo
6177 . remote_at ( "https://github.com/foobar/gitoxide" . to_owned ( ) ) ?
6278 . push_url ( "file://dev/null" . to_owned ( ) ) ?;
@@ -87,6 +103,18 @@ mod remote_at {
87103 "push is the same as fetch was rewritten"
88104 ) ;
89105
106+ let remote = remote. with_url_without_url_rewrite ( "https://github.com/foobaz/gitoxide" ) ?;
107+ assert_eq ! (
108+ remote. url( Direction :: Fetch ) . unwrap( ) . to_bstring( ) ,
109+ "https://github.com/foobaz/gitoxide" ,
110+ "fetch was rewritten"
111+ ) ;
112+ assert_eq ! (
113+ remote. url( Direction :: Push ) . unwrap( ) . to_bstring( ) ,
114+ "https://github.com/foobaz/gitoxide" ,
115+ "push is the same as fetch was rewritten"
116+ ) ;
117+
90118 let remote = repo
91119 . remote_at_without_url_rewrite ( "https://github.com/foobar/gitoxide" . to_owned ( ) ) ?
92120 . push_url_without_url_rewrite ( "file://dev/null" . to_owned ( ) ) ?;
@@ -96,6 +124,19 @@ mod remote_at {
96124 "file://dev/null" ,
97125 "push-url rewrite rules are not applied"
98126 ) ;
127+
128+ let remote = remote
129+ . with_url_without_url_rewrite ( "https://github.com/foobaz/gitoxide" . to_owned ( ) ) ?
130+ . push_url_without_url_rewrite ( "file://dev/null" . to_owned ( ) ) ?;
131+ assert_eq ! (
132+ remote. url( Direction :: Fetch ) . unwrap( ) . to_bstring( ) ,
133+ "https://github.com/foobaz/gitoxide"
134+ ) ;
135+ assert_eq ! (
136+ remote. url( Direction :: Push ) . unwrap( ) . to_bstring( ) ,
137+ "file://dev/null" ,
138+ "push-url rewrite rules are not applied"
139+ ) ;
99140 Ok ( ( ) )
100141 }
101142}
0 commit comments