File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed
Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -25,26 +25,26 @@ impl UpstreamIndex {
2525 }
2626
2727 /// Obtain a list of crates from the index HEAD
28- pub fn crates_from_index_head ( & self , crate_name : & str ) -> Vec < cargo_registry:: git:: Crate > {
28+ pub fn crates_from_index_head (
29+ & self ,
30+ crate_name : & str ,
31+ ) -> anyhow:: Result < Vec < cargo_registry:: git:: Crate > > {
2932 let repo = & self . repository ;
3033
3134 let path = cargo_registry:: git:: Repository :: relative_index_file ( crate_name) ;
32- let tree = repo. head ( ) . unwrap ( ) . peel_to_tree ( ) . unwrap ( ) ;
33- let blob = tree
34- . get_path ( & path)
35- . unwrap ( )
36- . to_object ( repo)
37- . unwrap ( )
38- . peel_to_blob ( )
39- . unwrap ( ) ;
35+
36+ let head = repo. head ( ) ?;
37+ let tree = head. peel_to_tree ( ) ?;
38+ let blob = tree. get_path ( & path) ?. to_object ( repo) ?. peel_to_blob ( ) ?;
39+
4040 let content = blob. content ( ) ;
4141
4242 // The index format consists of one JSON object per line
4343 // It is not a JSON array
44- let lines = std:: str:: from_utf8 ( content) . unwrap ( ) . lines ( ) ;
45- lines
46- . map ( |line| serde_json :: from_str ( line ) . unwrap ( ) )
47- . collect ( )
44+ let lines = std:: str:: from_utf8 ( content) ? . lines ( ) ;
45+ let versions = lines. map ( serde_json :: from_str ) . collect :: < Result < _ , _ > > ( ) ? ;
46+
47+ Ok ( versions )
4848 }
4949
5050 pub fn create_empty_commit ( & self ) -> anyhow:: Result < ( ) > {
Original file line number Diff line number Diff line change @@ -134,7 +134,9 @@ impl TestApp {
134134
135135 /// Obtain a list of crates from the index HEAD
136136 pub fn crates_from_index_head ( & self , crate_name : & str ) -> Vec < cargo_registry:: git:: Crate > {
137- self . upstream_index ( ) . crates_from_index_head ( crate_name)
137+ self . upstream_index ( )
138+ . crates_from_index_head ( crate_name)
139+ . unwrap ( )
138140 }
139141
140142 pub fn run_pending_background_jobs ( & self ) {
You can’t perform that action at this time.
0 commit comments