@@ -105,6 +105,8 @@ pub enum ToolchainParseError {
105
105
InvalidFlag ( String ) ,
106
106
#[ error( "invalid toolchain SHA: {0} is missing a `try#` or `master#` prefix" ) ]
107
107
PrefixMissing ( String ) ,
108
+ #[ error( "invalid url {0:?}: {1}" ) ]
109
+ InvalidUrl ( String , url:: ParseError ) ,
108
110
}
109
111
110
112
lazy_static ! {
@@ -187,7 +189,9 @@ impl FromStr for Toolchain {
187
189
#[ derive( Serialize , Deserialize , PartialEq , Eq , Hash , Debug , Clone ) ]
188
190
pub struct CratePatch {
189
191
pub name : String ,
190
- pub repo : String ,
192
+ // cargo currently doesn't accept scp-style "URLs" rust-lang/crates#1851
193
+ // so ensure its a proper URL
194
+ pub repo : url:: Url ,
191
195
pub branch : String ,
192
196
}
193
197
@@ -202,7 +206,8 @@ impl FromStr for CratePatch {
202
206
} else {
203
207
Ok ( CratePatch {
204
208
name : params[ 0 ] . into ( ) ,
205
- repo : params[ 1 ] . into ( ) ,
209
+ repo : url:: Url :: parse ( params[ 1 ] )
210
+ . map_err ( |err| ToolchainParseError :: InvalidUrl ( params[ 1 ] . into ( ) , err) ) ?,
206
211
branch : params[ 2 ] . into ( ) ,
207
212
} )
208
213
}
@@ -291,7 +296,7 @@ mod tests {
291
296
ci_try: $ci_try,
292
297
patches: vec![ CratePatch {
293
298
name: "example" . to_string( ) ,
294
- repo: "https://git.example.com/some/repo" . to_string ( ) ,
299
+ repo: url :: Url :: parse ( "https://git.example.com/some/repo" ) . unwrap ( ) ,
295
300
branch: "master" . to_string( )
296
301
} ]
297
302
} ) ;
@@ -306,7 +311,7 @@ mod tests {
306
311
ci_try: $ci_try,
307
312
patches: vec![ CratePatch {
308
313
name: "example" . to_string( ) ,
309
- repo: "https://git.example.com/some/repo" . to_string ( ) ,
314
+ repo: url :: Url :: parse ( "https://git.example.com/some/repo" ) . unwrap ( ) ,
310
315
branch: "master" . to_string( )
311
316
} ]
312
317
} ) ;
0 commit comments