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 {
25
25
}
26
26
27
27
/// 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 > > {
29
32
let repo = & self . repository ;
30
33
31
34
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
+
40
40
let content = blob. content ( ) ;
41
41
42
42
// The index format consists of one JSON object per line
43
43
// 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 )
48
48
}
49
49
50
50
pub fn create_empty_commit ( & self ) -> anyhow:: Result < ( ) > {
Original file line number Diff line number Diff line change @@ -134,7 +134,9 @@ impl TestApp {
134
134
135
135
/// Obtain a list of crates from the index HEAD
136
136
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 ( )
138
140
}
139
141
140
142
pub fn run_pending_background_jobs ( & self ) {
You can’t perform that action at this time.
0 commit comments