@@ -39,14 +39,34 @@ pub mod engine {
39
39
40
40
/// Run on the existing set of repositories we have already seen or obtain them from `path` if there is none yet.
41
41
pub fn run ( & mut self , corpus_path : PathBuf ) -> anyhow:: Result < ( ) > {
42
- let corpus_path = gix:: path:: realpath ( corpus_path) ?;
43
- let corpus_id = self . corpus_id_or_insert ( & corpus_path) ?;
42
+ let ( corpus_path, corpus_id) = self . prepare_corpus_path ( corpus_path) ?;
44
43
let _gitoxide_id = self . gitoxide_version_id_or_insert ( ) ?;
45
44
let _runner_id = self . runner_id_or_insert ( ) ?;
46
45
let _repos = self . find_repos_or_insert ( & corpus_path, corpus_id) ?;
47
46
todo ! ( "do run on repos" )
48
47
}
49
48
49
+ pub fn refresh ( & mut self , corpus_path : PathBuf ) -> anyhow:: Result < ( ) > {
50
+ let ( corpus_path, corpus_id) = self . prepare_corpus_path ( corpus_path) ?;
51
+ let repos = self . refresh_repos ( & corpus_path, corpus_id) ?;
52
+ self . progress . info ( format ! (
53
+ "Added or updated {} repositories under {corpus_path:?}" ,
54
+ repos. len( )
55
+ ) ) ;
56
+ Ok ( ( ) )
57
+ }
58
+ }
59
+
60
+ impl < P > Engine < P >
61
+ where
62
+ P : gix:: Progress ,
63
+ {
64
+ fn prepare_corpus_path ( & self , corpus_path : PathBuf ) -> anyhow:: Result < ( PathBuf , Id ) > {
65
+ let corpus_path = gix:: path:: realpath ( corpus_path) ?;
66
+ let corpus_id = self . corpus_id_or_insert ( & corpus_path) ?;
67
+ Ok ( ( corpus_path, corpus_id) )
68
+ }
69
+
50
70
fn find_repos ( & mut self , corpus_id : Id ) -> anyhow:: Result < Vec < db:: Repo > > {
51
71
self . progress . set_name ( "query db-repos" ) ;
52
72
self . progress . init ( None , gix:: progress:: count ( "repos" ) ) ;
0 commit comments