@@ -390,14 +390,48 @@ def git_commits_per_date() -> None:
390
390
Displays commits grouped by date.
391
391
"""
392
392
393
- cmd = ['git' , 'log' , '--date=short' , '--pretty=format:%cd' ]
393
+ # Customizable vars in the future
394
+ mailmap = "--use-mailmap"
395
+ merges = "--no-merges"
396
+ #log_options
397
+ #pathspec
398
+
399
+ # Since can be hardcoded for now. It'll be based on the earliest commit
400
+ # in the repo
401
+ earliest_commit_date = run_git_command (['git' , 'log' , '--reverse' , '--format=%ad' ])
402
+ if earliest_commit_date :
403
+ # Take the first line as the earliest commit date
404
+ first_commit_date = earliest_commit_date .split ('\n ' )[0 ]
405
+ since = f"--since='{ first_commit_date } '"
406
+ else :
407
+ # If no commits, set since to an empty string
408
+ since = ''
409
+
410
+ # Until will be current system's date and time
411
+ now = datetime .now (timezone .utc ).astimezone ()
412
+ until_formatted = now .strftime ('%a, %d %b %Y %H:%M:%S %Z' )
413
+ until = f"--until='{ until_formatted } '"
414
+
415
+ # Original command
416
+ # git -c log.showSignature=false log --use-mailmap $_merges "$_since" "$_until" \
417
+ # --date=short --format='%ad' $_log_options $_pathspec | sort | uniq -c
418
+ cmd = ['git' , '-c' , 'log.showSignature=false' , 'log' , mailmap , merges ,
419
+ since , until , '--date=short' , '--pretty=format:%ad' ]
420
+
421
+ # Print out the commit count and date in YYYY-MM-DD format
394
422
output = run_git_command (cmd )
395
423
if output :
396
424
dates = output .split ('\n ' )
397
425
counter = collections .Counter (dates )
398
- print ("Git commits per date:" )
426
+ print ("Git commits per date:\n " )
427
+
428
+ # Need to figure out the max count for width alignment purposes
429
+ max_count = max (counter .values ())
430
+ count_width = len (str (max_count ))
431
+
432
+ # Can now display this to the terminal
399
433
for date , count in sorted (counter .items ()):
400
- print (f"{ date } : { count } commits " )
434
+ print (f"\t { count :>{ count_width } } { date } " )
401
435
else :
402
436
print ('No commits found.' )
403
437
@@ -414,7 +448,7 @@ def git_commits_per_month() -> None:
414
448
counter = collections .Counter (months )
415
449
print ("Git commits per month:" )
416
450
for month , count in sorted (counter .items ()):
417
- print (f"{ month } : { count } commits" )
451
+ print (f"{ month } { count } commits" )
418
452
else :
419
453
print ('No commits found.' )
420
454
0 commit comments