@@ -105,6 +105,8 @@ pub enum ToolchainParseError {
105105 InvalidFlag ( String ) ,
106106 #[ error( "invalid toolchain SHA: {0} is missing a `try#` or `master#` prefix" ) ]
107107 PrefixMissing ( String ) ,
108+ #[ error( "invalid url {0:?}: {1}" ) ]
109+ InvalidUrl ( String , url:: ParseError ) ,
108110}
109111
110112lazy_static ! {
@@ -187,7 +189,9 @@ impl FromStr for Toolchain {
187189#[ derive( Serialize , Deserialize , PartialEq , Eq , Hash , Debug , Clone ) ]
188190pub struct CratePatch {
189191 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 ,
191195 pub branch : String ,
192196}
193197
@@ -202,7 +206,8 @@ impl FromStr for CratePatch {
202206 } else {
203207 Ok ( CratePatch {
204208 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) ) ?,
206211 branch : params[ 2 ] . into ( ) ,
207212 } )
208213 }
@@ -291,7 +296,7 @@ mod tests {
291296 ci_try: $ci_try,
292297 patches: vec![ CratePatch {
293298 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 ( ) ,
295300 branch: "master" . to_string( )
296301 } ]
297302 } ) ;
@@ -306,7 +311,7 @@ mod tests {
306311 ci_try: $ci_try,
307312 patches: vec![ CratePatch {
308313 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 ( ) ,
310315 branch: "master" . to_string( )
311316 } ]
312317 } ) ;
0 commit comments