@@ -8,7 +8,7 @@ use common::{
88use resolver:: {
99 ResolutionHandler , Resolver ,
1010 files:: { FilesResolver , FilesResource } ,
11- git:: { GitDependencyDescription , GitResolver , GitResource } ,
11+ git:: { GitDescription , GitResolver , GitResource } ,
1212 graph:: { DiGraph , GraphResolutionHandler , petgraph:: visit:: EdgeRef } ,
1313} ;
1414use smol_str:: SmolStr ;
@@ -18,13 +18,13 @@ use crate::{IngotInitDiagnostics, ingot_files_resolver};
1818
1919#[ derive( Clone ) ]
2020struct RemoteFilesContext {
21- description : GitDependencyDescription ,
21+ description : GitDescription ,
2222 checkout_path : Utf8PathBuf ,
2323}
2424
2525pub struct RemoteIngotHandler < ' a > {
2626 pub db : & ' a mut dyn InputDb ,
27- ingot_urls : HashMap < GitDependencyDescription , Url > ,
27+ ingot_urls : HashMap < GitDescription , Url > ,
2828 pub diagnostics : Vec < IngotInitDiagnostics > ,
2929 current_context : Option < RemoteFilesContext > ,
3030}
@@ -39,7 +39,7 @@ impl<'a> RemoteIngotHandler<'a> {
3939 }
4040 }
4141
42- pub fn ingot_url ( & self , description : & GitDependencyDescription ) -> Option < & Url > {
42+ pub fn ingot_url ( & self , description : & GitDescription ) -> Option < & Url > {
4343 self . ingot_urls . get ( description)
4444 }
4545
@@ -66,7 +66,7 @@ impl<'a> RemoteIngotHandler<'a> {
6666 has_config. then_some ( ( ) )
6767 }
6868
69- fn register_remote_mapping ( & mut self , ingot_url : & Url , description : & GitDependencyDescription ) {
69+ fn register_remote_mapping ( & mut self , ingot_url : & Url , description : & GitDescription ) {
7070 let remote = RemoteFiles {
7171 source : description. source . clone ( ) ,
7272 rev : SmolStr :: new ( description. rev . clone ( ) ) ,
@@ -84,12 +84,12 @@ impl<'a> RemoteIngotHandler<'a> {
8484 dependency : DependencyLocation ,
8585 alias : SmolStr ,
8686 arguments : DependencyArguments ,
87- ) -> Option < ( GitDependencyDescription , ( SmolStr , DependencyArguments ) ) > {
87+ ) -> Option < ( GitDescription , ( SmolStr , DependencyArguments ) ) > {
8888 match dependency {
8989 DependencyLocation :: Local ( local) => {
9090 match relative_path_within_checkout ( context. checkout_path . as_path ( ) , & local. url ) {
9191 Ok ( relative_path) => {
92- let mut next_description = GitDependencyDescription :: new (
92+ let mut next_description = GitDescription :: new (
9393 context. description . source . clone ( ) ,
9494 context. description . rev . clone ( ) ,
9595 ) ;
@@ -111,7 +111,7 @@ impl<'a> RemoteIngotHandler<'a> {
111111 }
112112 DependencyLocation :: Remote ( remote) => {
113113 let mut next_description =
114- GitDependencyDescription :: new ( remote. source . clone ( ) , remote. rev . to_string ( ) ) ;
114+ GitDescription :: new ( remote. source . clone ( ) , remote. rev . to_string ( ) ) ;
115115 if let Some ( path) = remote. path . clone ( ) {
116116 next_description = next_description. with_path ( path) ;
117117 }
@@ -123,31 +123,42 @@ impl<'a> RemoteIngotHandler<'a> {
123123
124124impl < ' a > ResolutionHandler < GitResolver > for RemoteIngotHandler < ' a > {
125125 type Item = Vec < (
126- GitDependencyDescription ,
126+ GitDescription ,
127127 ( DependencyAlias , DependencyArguments ) ,
128128 ) > ;
129129
130130 fn handle_resolution (
131131 & mut self ,
132- description : & GitDependencyDescription ,
132+ description : & GitDescription ,
133133 resource : GitResource ,
134134 ) -> Self :: Item {
135+ // Compute ingot_path based on description.path
136+ let ingot_path = if let Some ( relative) = & description. path {
137+ resource. checkout_path . join ( relative)
138+ } else {
139+ resource. checkout_path . clone ( )
140+ } ;
141+
142+ // Convert ingot_path to URL
143+ let ingot_url = Url :: from_directory_path ( ingot_path. as_std_path ( ) )
144+ . expect ( "Failed to convert ingot path to URL" ) ;
145+
135146 self . ingot_urls
136- . insert ( description. clone ( ) , resource . ingot_url . clone ( ) ) ;
147+ . insert ( description. clone ( ) , ingot_url. clone ( ) ) ;
137148
138149 let mut files_resolver = ingot_files_resolver ( ) ;
139150 self . current_context = Some ( RemoteFilesContext {
140151 description : description. clone ( ) ,
141152 checkout_path : resource. checkout_path . clone ( ) ,
142153 } ) ;
143- let files_result = files_resolver. resolve ( self , & resource . ingot_url ) ;
154+ let files_result = files_resolver. resolve ( self , & ingot_url) ;
144155 self . current_context = None ;
145156
146157 for diagnostic in files_resolver. take_diagnostics ( ) {
147158 let target_url = diagnostic
148159 . url ( )
149160 . cloned ( )
150- . unwrap_or_else ( || resource . ingot_url . clone ( ) ) ;
161+ . unwrap_or_else ( || ingot_url. clone ( ) ) ;
151162 self . diagnostics
152163 . push ( IngotInitDiagnostics :: RemoteFileError {
153164 ingot_url : target_url,
@@ -160,7 +171,7 @@ impl<'a> ResolutionHandler<GitResolver> for RemoteIngotHandler<'a> {
160171 Err ( error) => {
161172 self . diagnostics
162173 . push ( IngotInitDiagnostics :: RemoteFileError {
163- ingot_url : resource . ingot_url . clone ( ) ,
174+ ingot_url : ingot_url. clone ( ) ,
164175 error : error. to_string ( ) ,
165176 } ) ;
166177 Vec :: new ( )
@@ -171,7 +182,7 @@ impl<'a> ResolutionHandler<GitResolver> for RemoteIngotHandler<'a> {
171182
172183impl < ' a > ResolutionHandler < FilesResolver > for RemoteIngotHandler < ' a > {
173184 type Item = Vec < (
174- GitDependencyDescription ,
185+ GitDescription ,
175186 ( DependencyAlias , DependencyArguments ) ,
176187 ) > ;
177188
@@ -242,16 +253,16 @@ impl<'a> ResolutionHandler<FilesResolver> for RemoteIngotHandler<'a> {
242253
243254impl < ' a >
244255 GraphResolutionHandler <
245- GitDependencyDescription ,
246- DiGraph < GitDependencyDescription , ( DependencyAlias , DependencyArguments ) > ,
256+ GitDescription ,
257+ DiGraph < GitDescription , ( DependencyAlias , DependencyArguments ) > ,
247258 > for RemoteIngotHandler < ' a >
248259{
249260 type Item = DiGraph < Url , ( DependencyAlias , DependencyArguments ) > ;
250261
251262 fn handle_graph_resolution (
252263 & mut self ,
253- _description : & GitDependencyDescription ,
254- graph : DiGraph < GitDependencyDescription , ( DependencyAlias , DependencyArguments ) > ,
264+ _description : & GitDescription ,
265+ graph : DiGraph < GitDescription , ( DependencyAlias , DependencyArguments ) > ,
255266 ) -> Self :: Item {
256267 let mut converted: DiGraph < Url , ( DependencyAlias , DependencyArguments ) > = DiGraph :: new ( ) ;
257268 let mut node_map = HashMap :: new ( ) ;
0 commit comments