@@ -54,7 +54,7 @@ def _get_author_last_edit(author: str, path: str, cwd: str | None = None) -> str
5454 return "unknown"
5555
5656
57- def _repo_level (n : int , since : str | None , show_email : bool ) -> None :
57+ def _repo_level (n : int , since : str | None , show_email : bool = False ) -> None :
5858 """Show top contributors to the entire repo."""
5959 args = ["shortlog" , "-sne" , "--all" ]
6060 if since :
@@ -121,24 +121,30 @@ def union(a: int, b: int) -> None:
121121 else :
122122 key_to_idx [key ] = idx
123123
124- # Merge grouped entries
124+ # Merge grouped entries, collecting all emails per group
125125 groups : dict [int , dict [str , str | int ]] = {}
126+ group_emails : dict [int , set [str ]] = {}
126127 for idx , entry in enumerate (raw_entries ):
127128 root = find (idx )
128129 e_name = str (entry ["name" ])
129130 e_email = str (entry ["email" ])
130131 e_commits = int (entry ["commits" ])
131132 if root in groups :
132133 groups [root ]["commits" ] = int (groups [root ]["commits" ]) + e_commits
133- # Keep the longest name (most likely the real full name)
134134 if len (e_name ) > len (str (groups [root ]["name" ])):
135135 groups [root ]["name" ] = e_name
136- if e_email and not groups [root ]["email" ]:
137- groups [root ]["email" ] = e_email
138136 else :
139137 groups [root ] = {"name" : e_name , "email" : e_email , "commits" : e_commits }
138+ group_emails [root ] = set ()
139+ if e_email :
140+ group_emails [root ].add (e_email )
140141
141142 contributors = sorted (groups .values (), key = lambda c : c ["commits" ], reverse = True )
143+ # Build ordered email sets matching contributor order
144+ contributor_emails = [
145+ group_emails [root ]
146+ for root in sorted (groups .keys (), key = lambda r : int (groups [r ]["commits" ]), reverse = True )
147+ ]
142148
143149 # Get current git user (both name and email for matching)
144150 try :
@@ -153,20 +159,19 @@ def union(a: int, b: int) -> None:
153159 rows = []
154160 for i , c in enumerate (contributors [:n ], 1 ):
155161 name = str (c ["name" ])
156- email_addr = str ( c [ "email" ])
162+ emails = sorted ( contributor_emails [ i - 1 ]) if i - 1 < len ( contributor_emails ) else []
157163 is_you = (
158- (current_user_email and email_addr == current_user_email )
164+ (current_user_email and current_user_email in { e . lower () for e in emails } )
159165 or (current_user_name and name == current_user_name )
160166 )
161167 display_name = "You" if is_you else name
162- if show_email and email_addr :
163- display_name += f" <{ email_addr } >"
168+ email_col = ", " .join (emails ) if emails else ""
164169 last_active = _get_author_last_edit (name , "." )
165- rows .append ([str (i ), display_name , str (c ["commits" ]), last_active ])
170+ rows .append ([str (i ), display_name , email_col , str (c ["commits" ]), last_active ])
166171
167172 console .print ()
168173 print_table (
169- headers = ["#" , "Author" , "Commits" , "Last Active" ],
174+ headers = ["#" , "Author" , "Email" , " Commits" , "Last Active" ],
170175 rows = rows ,
171176 title = "Top contributors" ,
172177 )
0 commit comments