File tree Expand file tree Collapse file tree 2 files changed +25
-19
lines changed Expand file tree Collapse file tree 2 files changed +25
-19
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,29 @@ impl UpstreamIndex {
24
24
Url :: from_file_path ( & bare ( ) ) . unwrap ( )
25
25
}
26
26
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 > {
29
+ let repo = & self . repository ;
30
+
31
+ 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 ( ) ;
40
+ let content = blob. content ( ) ;
41
+
42
+ // The index format consists of one JSON object per line
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 ( )
48
+ }
49
+
27
50
pub fn create_empty_commit ( & self ) -> anyhow:: Result < ( ) > {
28
51
let repo = & self . repository ;
29
52
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use cargo_registry::{
11
11
} ;
12
12
use std:: { rc:: Rc , sync:: Arc , time:: Duration } ;
13
13
14
- use cargo_registry:: git:: { Repository as WorkerRepository , Repository } ;
14
+ use cargo_registry:: git:: Repository as WorkerRepository ;
15
15
use diesel:: PgConnection ;
16
16
use reqwest:: { blocking:: Client , Proxy } ;
17
17
use std:: collections:: HashSet ;
@@ -139,24 +139,7 @@ impl TestApp {
139
139
140
140
/// Obtain a list of crates from the index HEAD
141
141
pub fn crates_from_index_head ( & self , crate_name : & str ) -> Vec < cargo_registry:: git:: Crate > {
142
- let path = Repository :: relative_index_file ( crate_name) ;
143
- let index = self . upstream_repository ( ) ;
144
- let tree = index. head ( ) . unwrap ( ) . peel_to_tree ( ) . unwrap ( ) ;
145
- let blob = tree
146
- . get_path ( & path)
147
- . unwrap ( )
148
- . to_object ( index)
149
- . unwrap ( )
150
- . peel_to_blob ( )
151
- . unwrap ( ) ;
152
- let content = blob. content ( ) ;
153
-
154
- // The index format consists of one JSON object per line
155
- // It is not a JSON array
156
- let lines = std:: str:: from_utf8 ( content) . unwrap ( ) . lines ( ) ;
157
- lines
158
- . map ( |line| serde_json:: from_str ( line) . unwrap ( ) )
159
- . collect ( )
142
+ self . upstream_index ( ) . crates_from_index_head ( crate_name)
160
143
}
161
144
162
145
pub fn run_pending_background_jobs ( & self ) {
You can’t perform that action at this time.
0 commit comments