@@ -288,17 +288,21 @@ impl Info {
288
288
custom_image : Option < DynamicImage > ,
289
289
no_merges : bool ,
290
290
) -> Result < Info > {
291
- let authors = Info :: get_authors ( & dir, no_merges, 3 ) ;
292
- let ( git_v, git_user) = Info :: get_git_info ( & dir) ;
293
- let current_commit_info = Info :: get_current_commit_info ( & dir) ?;
294
- let config = Info :: get_configuration ( & dir) ?;
295
- let version = Info :: get_version ( & dir) ?;
296
- let commits = Info :: get_commits ( & dir, no_merges) ?;
297
- let repo_size = Info :: get_packed_size ( & dir) ?;
298
- let last_change = Info :: get_last_change ( & dir) ?;
299
- let creation_date = Info :: get_creation_time ( dir) ?;
300
- let project_license = Info :: get_project_license ( & dir) ?;
301
- let ( languages_stats, number_of_lines) = Language :: get_language_stats ( & dir) ?;
291
+ let repo = Repository :: discover ( & dir) . map_err ( |_| Error :: NotGitRepo ) ?;
292
+ let workdir = repo. workdir ( ) . ok_or ( Error :: BareGitRepo ) ?;
293
+ let workdir_str = workdir. to_str ( ) . unwrap ( ) ;
294
+
295
+ let authors = Info :: get_authors ( workdir_str, no_merges, 3 ) ;
296
+ let ( git_v, git_user) = Info :: get_git_info ( workdir_str) ;
297
+ let current_commit_info = Info :: get_current_commit_info ( & repo) ?;
298
+ let config = Info :: get_configuration ( & repo) ?;
299
+ let version = Info :: get_version ( workdir_str) ?;
300
+ let commits = Info :: get_commits ( workdir_str, no_merges) ?;
301
+ let repo_size = Info :: get_packed_size ( workdir_str) ?;
302
+ let last_change = Info :: get_last_change ( workdir_str) ?;
303
+ let creation_date = Info :: get_creation_time ( workdir_str) ?;
304
+ let project_license = Info :: get_project_license ( workdir_str) ?;
305
+ let ( languages_stats, number_of_lines) = Language :: get_language_stats ( workdir_str) ?;
302
306
let dominant_language = Language :: get_dominant_language ( languages_stats. clone ( ) ) ;
303
307
304
308
Ok ( Info {
@@ -390,8 +394,7 @@ impl Info {
390
394
( version, username)
391
395
}
392
396
393
- fn get_current_commit_info ( dir : & str ) -> Result < CommitInfo > {
394
- let repo = Repository :: discover ( dir) . map_err ( |_| Error :: NotGitRepo ) ?;
397
+ fn get_current_commit_info ( repo : & Repository ) -> Result < CommitInfo > {
395
398
let head = repo. head ( ) . map_err ( |_| Error :: ReferenceInfoError ) ?;
396
399
let head_oid = head. target ( ) . ok_or ( Error :: ReferenceInfoError ) ?;
397
400
let refs = repo. references ( ) . map_err ( |_| Error :: ReferenceInfoError ) ?;
@@ -413,8 +416,7 @@ impl Info {
413
416
Ok ( CommitInfo :: new ( head_oid, refs_info) )
414
417
}
415
418
416
- fn get_configuration ( dir : & str ) -> Result < Configuration > {
417
- let repo = Repository :: discover ( dir) . map_err ( |_| Error :: NotGitRepo ) ?;
419
+ fn get_configuration ( repo : & Repository ) -> Result < Configuration > {
418
420
let config = repo. config ( ) . map_err ( |_| Error :: NoGitData ) ?;
419
421
let mut remote_url = String :: new ( ) ;
420
422
let mut repository_name = String :: new ( ) ;
0 commit comments