4
4
5
5
import collections
6
6
import re
7
- from datetime import datetime , timezone
7
+ from datetime import datetime
8
8
from typing import Dict , Union , Optional
9
9
10
10
from git_py_stats .git_operations import run_git_command
13
13
def branch_tree (config : Dict [str , Union [str , int ]]) -> None :
14
14
"""
15
15
Displays a visual graph of recent commits across all branches.
16
-
16
+
17
17
Args:
18
18
config: Dict[str, Union[str, int]]: Config dictionary holding env vars.
19
19
@@ -24,19 +24,22 @@ def branch_tree(config: Dict[str, Union[str, int]]) -> None:
24
24
# Grab the config options from our config.py.
25
25
# config.py should give fallbacks for these, but for sanity, lets
26
26
# also provide some defaults just in case.
27
- merges = config .get ("merges" , "--no-merges" )
28
27
since = config .get ("since" , "" )
29
28
until = config .get ("until" , "" )
30
29
log_options = config .get ("log_options" , "" )
31
30
limit = config .get ("limit" , 10 )
32
31
33
32
# Format string for git --format so it gets interpreted correctly
34
- format_str = "--format=--+ Commit: %h%n | Date: %aD (%ar)%n | Message: %s %d%n + Author: %aN %n"
33
+ format_str = (
34
+ "--format=--+ Commit: %h%n | Date: %aD (%ar)%n | "
35
+ "Message: %s %d%n + Author: %aN %n"
36
+ )
35
37
36
38
# Original command:
37
39
# git -c log.showSignature=false log --use-mailmap --graph --abbrev-commit \
38
40
# "$_since" "$_until" --decorate \
39
- # --format=format:'--+ Commit: %h %n | Date: %aD (%ar) %n'' | Message: %s %d %n'' + Author: %aN %n' \
41
+ # --format=format:'--+ Commit: %h %n | Date: %aD (%ar) %n'' \
42
+ # | Message: %s %d %n'' + Author: %aN %n' \
40
43
# --all $_log_options | head -n $((_limit*5))
41
44
cmd = [
42
45
"git" ,
@@ -69,9 +72,9 @@ def branch_tree(config: Dict[str, Union[str, int]]) -> None:
69
72
for line in limited_lines :
70
73
print (f"{ line } " )
71
74
72
- commit_count = sum (
73
- 1 for line in limited_lines if line .strip ().startswith ("--+ Commit:" )
74
- )
75
+ # commit_count = sum(
76
+ # 1 for line in limited_lines if line.strip().startswith("--+ Commit:")
77
+ # )
75
78
else :
76
79
print ("No data available." )
77
80
@@ -175,19 +178,14 @@ def contributors(config: Dict[str, Union[str, int]]) -> None:
175
178
limited_authors = sorted_authors [:limit ]
176
179
177
180
# Number the authors similar to 'cat -n' and print
178
- numbered_authors = [
179
- f"{ idx + 1 } { author } " for idx , author in enumerate (limited_authors )
180
- ]
181
+ numbered_authors = [f"{ idx + 1 } { author } " for idx , author in enumerate (limited_authors )]
181
182
for author in numbered_authors :
182
183
print (f"\t { author } " )
183
184
else :
184
185
print ("No contributors found." )
185
186
186
187
187
- def new_contributors (
188
- config : Dict [str , Union [str , int ]],
189
- new_date : str
190
- ) -> None :
188
+ def new_contributors (config : Dict [str , Union [str , int ]], new_date : str ) -> None :
191
189
"""
192
190
Lists all new contributors to a repo since the specified date.
193
191
@@ -248,10 +246,7 @@ def new_contributors(
248
246
email , timestamp = line .split ("|" )
249
247
timestamp = int (timestamp )
250
248
# If the contributor is not in the dictionary or the current timestamp is earlier
251
- if (
252
- email not in contributors_dict
253
- or timestamp < contributors_dict [email ]
254
- ):
249
+ if email not in contributors_dict or timestamp < contributors_dict [email ]:
255
250
contributors_dict [email ] = timestamp
256
251
except ValueError :
257
252
continue # Skip lines that don't match format
@@ -298,9 +293,7 @@ def new_contributors(
298
293
# and print all of this out
299
294
if new_contributors_list :
300
295
print (f"New contributors since { new_date } :\n " )
301
- sorted_new_contributors = sorted (
302
- new_contributors_list , key = lambda x : (x [0 ], x [1 ])
303
- )
296
+ sorted_new_contributors = sorted (new_contributors_list , key = lambda x : (x [0 ], x [1 ]))
304
297
for idx , (name , email ) in enumerate (sorted_new_contributors , 1 ):
305
298
if name :
306
299
print (f"{ name } <{ email } >" )
@@ -315,7 +308,7 @@ def new_contributors(
315
308
def git_commits_per_author (config : Dict [str , Union [str , int ]]) -> None :
316
309
"""
317
310
Shows the number of commits per author.
318
-
311
+
319
312
Args:
320
313
config: Dict[str, Union[str, int]]: Config dictionary holding env vars.
321
314
@@ -443,7 +436,7 @@ def extract_name(author_info: str) -> Optional[str]:
443
436
def git_commits_per_date (config : Dict [str , Union [str , int ]]) -> None :
444
437
"""
445
438
Displays commits grouped by date.
446
-
439
+
447
440
Args:
448
441
config: Dict[str, Union[str, int]]: Config dictionary holding env vars.
449
442
@@ -575,9 +568,6 @@ def git_commits_per_month(config: Dict[str, Union[str, int]]) -> None:
575
568
if month in commit_counts :
576
569
commit_counts [month ] += 1
577
570
578
- # Calculate total commits
579
- total_commits = sum (commit_counts .values ())
580
-
581
571
# Determine the maximum count to set the scaling factor
582
572
max_count = max (commit_counts .values ()) if commit_counts else 0
583
573
@@ -610,7 +600,7 @@ def git_commits_per_month(config: Dict[str, Union[str, int]]) -> None:
610
600
def git_commits_per_year (config : Dict [str , Union [str , int ]]) -> None :
611
601
"""
612
602
Displays commits grouped by year.
613
-
603
+
614
604
Args:
615
605
config: Dict[str, Union[str, int]]: Config dictionary holding env vars.
616
606
@@ -681,10 +671,6 @@ def git_commits_per_year(config: Dict[str, Union[str, int]]) -> None:
681
671
max_count = max (commit_counts .values ())
682
672
scaling_factor = (max_bar_length / max_count ) if max_count > 0 else 0
683
673
684
- # Determine the width for alignment
685
- year_width = len (str (end_year ))
686
- count_width = len (str (max_count ))
687
-
688
674
# Print the header row
689
675
header_year = "Year"
690
676
header_sum = "Sum"
@@ -706,8 +692,7 @@ def git_commits_per_year(config: Dict[str, Union[str, int]]) -> None:
706
692
707
693
708
694
def git_commits_per_weekday (
709
- config : Dict [str , Union [str , int ]],
710
- author : Optional [str ] = None
695
+ config : Dict [str , Union [str , int ]], author : Optional [str ] = None
711
696
) -> None :
712
697
"""
713
698
Shows commits grouped by weekday. If an author is provided, it shows
@@ -784,9 +769,6 @@ def git_commits_per_weekday(
784
769
max_count = max (commit_counts .values ())
785
770
scaling_factor = (max_bar_length / max_count ) if max_count > 0 else 0
786
771
787
- # Determine the width for alignment based on max_count
788
- count_width = len (str (max_count ))
789
-
790
772
# Print the header row
791
773
header_day = "Day"
792
774
header_sum = "Sum"
@@ -816,10 +798,7 @@ def git_commits_per_weekday(
816
798
print ("No commits found." )
817
799
818
800
819
- def git_commits_per_hour (
820
- config : Dict [str , Union [str , int ]],
821
- author : Optional [str ] = None
822
- ) -> None :
801
+ def git_commits_per_hour (config : Dict [str , Union [str , int ]], author : Optional [str ] = None ) -> None :
823
802
"""
824
803
Shows commits grouped by hour of the day. If an author is provided,
825
804
it shows commits grouped by hour for that specific author.
@@ -896,9 +875,6 @@ def git_commits_per_hour(
896
875
max_count = max (commit_counts .values ())
897
876
scaling_factor = (max_bar_length / max_count ) if max_count > 0 else 0
898
877
899
- # Determine the width for alignment based on max_count
900
- count_width = len (str (max_count ))
901
-
902
878
# Print the header row
903
879
header_hour = "Hour"
904
880
header_sum = "Sum"
@@ -929,8 +905,7 @@ def git_commits_per_hour(
929
905
930
906
931
907
def git_commits_per_timezone (
932
- config : Dict [str , Union [str , int ]],
933
- author : Optional [str ] = None
908
+ config : Dict [str , Union [str , int ]], author : Optional [str ] = None
934
909
) -> None :
935
910
"""
936
911
Displays commits grouped by timezone. If an author is provided, it shows
0 commit comments