@@ -2,6 +2,7 @@ use std::borrow::Cow;
22use std:: collections:: btree_map:: Entry ;
33use std:: collections:: { BTreeMap , HashSet } ;
44use std:: io:: { IsTerminal , Read } ;
5+ use std:: path:: PathBuf ;
56use std:: sync:: { Arc , Mutex } ;
67use std:: time:: Duration ;
78
@@ -381,6 +382,7 @@ struct Run {
381382 masker : Arc < Masker > ,
382383 ids : Vec < i64 > ,
383384 cancel_behaviour : Option < JobCancelBehaviour > ,
385+ repo_path : Option < PathBuf > ,
384386}
385387
386388impl Run {
@@ -397,6 +399,11 @@ impl Run {
397399 . collect :: < Vec < _ > > ( ) ;
398400 let masker = Arc :: new ( Masker :: new ( & masked, MASK_PATTERN ) ) ;
399401
402+ let repo_path = job
403+ . checkout_repo ( )
404+ . map_err ( |e| outputln ! ( "Failed to checkout repo: {}" , e. to_string( ) ) )
405+ . ok ( ) ;
406+
400407 Self {
401408 lava : lava. clone ( ) ,
402409 store : Arc :: new ( AvailableArtifactStore :: new ( lava, masker. clone ( ) ) ) ,
@@ -405,10 +412,21 @@ impl Run {
405412 masker,
406413 ids : Vec :: new ( ) ,
407414 cancel_behaviour,
415+ repo_path,
408416 }
409417 }
410418
411419 async fn find_file ( & self , filename : & str ) -> Result < Vec < u8 > , ( ) > {
420+ if let Some ( repo_path) = & self . repo_path {
421+ let path = repo_path. join ( filename) ;
422+ if path. exists ( ) {
423+ let data = tokio:: fs:: read ( & path) . await . map_err ( |e| {
424+ outputln ! ( "Failed to read repo file {:?}: {}" , path, e. to_string( ) )
425+ } ) ?;
426+ return Ok ( data) ;
427+ }
428+ }
429+
412430 for d in self . job . dependencies ( ) {
413431 let artifact = match d. download ( ) . await {
414432 Ok ( a) => a,
@@ -434,7 +452,7 @@ impl Run {
434452 } ;
435453 }
436454 }
437- outputln ! ( "{} not found in artifacts" , filename) ;
455+ outputln ! ( "{} not found in repo or artifacts" , filename) ;
438456 Err ( ( ) )
439457 }
440458
0 commit comments