@@ -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 ) {
@@ -355,9 +355,13 @@ fn main() -> Result<()> {
355
355
let commits = get_commits ( & dir) ?;
356
356
let repo_size = get_packed_size ( & dir) ?;
357
357
let last_change = get_last_change ( & dir) ?;
358
+ let project_name = match get_creation_time ( ) {
359
+ Some ( creation_time) => format ! ( "{}, {}" , config. repository_name, creation_time) ,
360
+ None => config. repository_name
361
+ } ;
358
362
359
363
let info = Info {
360
- project_name : config . repository_name ,
364
+ project_name,
361
365
current_commit : current_commit_info,
362
366
version,
363
367
dominant_language,
@@ -513,7 +517,7 @@ fn get_packed_size(dir: &str) -> Result<String> {
513
517
None => "??" ,
514
518
Some ( size_str) => & ( size_str[ 11 ..] )
515
519
} ;
516
-
520
+
517
521
let output = Command :: new ( "git" )
518
522
. arg ( "-C" )
519
523
. arg ( dir)
@@ -539,7 +543,7 @@ fn get_packed_size(dir: &str) -> Result<String> {
539
543
else {
540
544
let res =repo_size;
541
545
Ok ( res. into ( ) )
542
- }
546
+ }
543
547
}
544
548
545
549
fn is_git_installed ( ) -> bool {
@@ -666,6 +670,23 @@ fn get_total_loc(languages: &tokei::Languages) -> usize {
666
670
. fold ( 0 , |sum, val| sum + val. code )
667
671
}
668
672
673
+ fn get_creation_time ( ) -> Option < String > {
674
+ let output = Command :: new ( "git" )
675
+ . arg ( "log" )
676
+ . arg ( "--reverse" )
677
+ . arg ( "--pretty=oneline" )
678
+ . arg ( "--format=\" %ar\" " )
679
+ . output ( )
680
+ . expect ( "Failed to execute git." ) ;
681
+
682
+ let output = String :: from_utf8_lossy ( & output. stdout ) ;
683
+
684
+ match output. lines ( ) . next ( ) {
685
+ Some ( val) => Some ( val. to_string ( ) . replace ( '"' , "" ) ) ,
686
+ None => None
687
+ }
688
+ }
689
+
669
690
/// Convert from tokei LanguageType to known Language type .
670
691
impl From < tokei:: LanguageType > for Language {
671
692
fn from ( language : tokei:: LanguageType ) -> Self {
0 commit comments