File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,35 @@ use git_repository as git;
2
2
use git_repository:: Reference ;
3
3
4
4
fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
5
- let repo = git:: discover ( "." ) ?. apply_environment ( ) ;
5
+ let mut repo = git:: discover ( "." ) ?. apply_environment ( ) ;
6
6
println ! (
7
7
"Repo: {}" ,
8
- repo. work_dir( ) . as_deref( ) . unwrap_or( repo. git_dir( ) ) . display( )
8
+ repo. work_dir( )
9
+ . as_deref( )
10
+ . unwrap_or( repo. git_dir( ) )
11
+ . display( )
9
12
) ;
13
+ let mut max_commit_size = 0 ;
14
+ let mut avg_commit_size = 0 ;
15
+ repo. object_cache_size ( 32 * 1024 ) ;
10
16
let commit_ids = repo
11
17
. head ( ) ?
12
18
. into_fully_peeled_id ( )
13
19
. ok_or_else ( || "There are no commits - nothing to do here." ) ??
14
20
. ancestors ( )
15
21
. all ( )
22
+ . inspect ( |id| {
23
+ if let Ok ( Ok ( object) ) = id. as_ref ( ) . map ( |id| id. object ( ) ) {
24
+ avg_commit_size += object. data . len ( ) ;
25
+ if object. data . len ( ) > max_commit_size {
26
+ max_commit_size = object. data . len ( ) ;
27
+ }
28
+ }
29
+ } )
16
30
. collect :: < Result < Vec < _ > , _ > > ( ) ?;
17
31
println ! ( "Num Commits: {}" , commit_ids. len( ) ) ;
32
+ println ! ( "Max commit Size: {}" , max_commit_size) ;
33
+ println ! ( "Avg commit Size: {}" , avg_commit_size / commit_ids. len( ) ) ;
18
34
assert ! ( !commit_ids. is_empty( ) , "checked that before" ) ;
19
35
20
36
let last_commit_id = & commit_ids[ 0 ] ;
You can’t perform that action at this time.
0 commit comments