@@ -2,12 +2,11 @@ use serialize::Decodable;
2
2
use std:: collections:: HashMap ;
3
3
use std:: str;
4
4
use toml;
5
- use url;
6
5
7
6
use core:: { SourceId , GitKind } ;
8
7
use core:: manifest:: { LibKind , Lib , Profile } ;
9
8
use core:: { Summary , Manifest , Target , Dependency , PackageId } ;
10
- use core:: source:: { Location , Local , Remote } ;
9
+ use core:: source:: Location ;
11
10
use util:: { CargoResult , Require , human} ;
12
11
13
12
pub fn to_manifest ( contents : & [ u8 ] ,
@@ -118,15 +117,6 @@ impl TomlManifest {
118
117
119
118
let mut deps = Vec :: new ( ) ;
120
119
121
- fn to_location ( s : & str ) -> Location {
122
- if s. starts_with ( "file:" ) {
123
- Local ( Path :: new ( s. slice_from ( 5 ) ) )
124
- } else {
125
- // TODO: Don't unwrap here
126
- Remote ( url:: from_str ( s) . unwrap ( ) )
127
- }
128
- }
129
-
130
120
// Collect the deps
131
121
match self . dependencies {
132
122
Some ( ref dependencies) => {
@@ -141,19 +131,22 @@ impl TomlManifest {
141
131
. or_else ( || details. rev . as_ref ( ) . map ( |t| t. clone ( ) ) )
142
132
. unwrap_or_else ( || "master" . to_str ( ) ) ;
143
133
144
- let new_source_id = details. git . as_ref ( ) . map ( |git| {
145
- let kind = GitKind ( reference. clone ( ) ) ;
146
- let loc = to_location ( git. as_slice ( ) ) ;
147
- let source_id = SourceId :: new ( kind, loc) ;
148
- // TODO: Don't do this for path
149
- sources. push ( source_id. clone ( ) ) ;
150
- source_id
151
- } ) . or_else ( || {
152
- details. path . as_ref ( ) . map ( |path| {
153
- nested_paths. push ( Path :: new ( path. as_slice ( ) ) ) ;
154
- source_id. clone ( )
155
- } )
156
- } ) . unwrap_or ( SourceId :: for_central ( ) ) ;
134
+ let new_source_id = match details. git {
135
+ Some ( ref git) => {
136
+ let kind = GitKind ( reference. clone ( ) ) ;
137
+ let loc = try!( Location :: parse ( git. as_slice ( ) ) ) ;
138
+ let source_id = SourceId :: new ( kind, loc) ;
139
+ // TODO: Don't do this for path
140
+ sources. push ( source_id. clone ( ) ) ;
141
+ Some ( source_id)
142
+ }
143
+ None => {
144
+ details. path . as_ref ( ) . map ( |path| {
145
+ nested_paths. push ( Path :: new ( path. as_slice ( ) ) ) ;
146
+ source_id. clone ( )
147
+ } )
148
+ }
149
+ } . unwrap_or ( SourceId :: for_central ( ) ) ;
157
150
158
151
( details. version . clone ( ) , new_source_id)
159
152
}
0 commit comments