@@ -182,9 +182,9 @@ fn count_newlines(s: &str) -> usize {
182
182
/// escape characters for color display.
183
183
///
184
184
/// Colors are specified with {0}, {1}... where the number represents
185
- /// the nth element in the colors Vec provided to the function.
185
+ /// the nth element in the colors Vec provided to the function.
186
186
/// If there are more colors in the ascii than in the Vec it
187
- /// defaults to white.
187
+ /// defaults to white.
188
188
/// The usize in the tuple refers to the extra padding needed
189
189
/// which comes from the added escape characters.
190
190
fn colorize_str ( line : & str , colors : Vec < Color > ) -> ( String , usize ) {
@@ -363,9 +363,13 @@ fn main() -> Result<()> {
363
363
let commits = get_commits ( & dir) ?;
364
364
let repo_size = get_packed_size ( & dir) ?;
365
365
let last_change = get_last_change ( & dir) ?;
366
+ let project_name = match get_creation_time ( ) {
367
+ Some ( creation_time) => format ! ( "{}, {}" , config. repository_name, creation_time) ,
368
+ None => config. repository_name
369
+ } ;
366
370
367
371
let info = Info {
368
- project_name : config . repository_name ,
372
+ project_name,
369
373
current_commit : current_commit_info,
370
374
version,
371
375
dominant_language,
@@ -521,7 +525,7 @@ fn get_packed_size(dir: &str) -> Result<String> {
521
525
None => "??" ,
522
526
Some ( size_str) => & ( size_str[ 11 ..] )
523
527
} ;
524
-
528
+
525
529
let output = Command :: new ( "git" )
526
530
. arg ( "-C" )
527
531
. arg ( dir)
@@ -547,7 +551,7 @@ fn get_packed_size(dir: &str) -> Result<String> {
547
551
else {
548
552
let res =repo_size;
549
553
Ok ( res. into ( ) )
550
- }
554
+ }
551
555
}
552
556
553
557
fn is_git_installed ( ) -> bool {
@@ -674,6 +678,23 @@ fn get_total_loc(languages: &tokei::Languages) -> usize {
674
678
. fold ( 0 , |sum, val| sum + val. code )
675
679
}
676
680
681
+ fn get_creation_time ( ) -> Option < String > {
682
+ let output = Command :: new ( "git" )
683
+ . arg ( "log" )
684
+ . arg ( "--reverse" )
685
+ . arg ( "--pretty=oneline" )
686
+ . arg ( "--format=\" %ar\" " )
687
+ . output ( )
688
+ . expect ( "Failed to execute git." ) ;
689
+
690
+ let output = String :: from_utf8_lossy ( & output. stdout ) ;
691
+
692
+ match output. lines ( ) . next ( ) {
693
+ Some ( val) => Some ( val. to_string ( ) . replace ( '"' , "" ) ) ,
694
+ None => None
695
+ }
696
+ }
697
+
677
698
/// Convert from tokei LanguageType to known Language type .
678
699
impl From < tokei:: LanguageType > for Language {
679
700
fn from ( language : tokei:: LanguageType ) -> Self {
0 commit comments