55# This hook is called when changesets are pushed to the default repository (ie 
66# `hg push`). See https://zulip.com/integrations for installation instructions. 
77
8+ import  re 
89import  sys 
910
1011from  mercurial  import  repository  as  repo 
1516VERSION  =  "0.9" 
1617
1718
19+ def  parse_user (user : str ) ->  str :
20+     """Extract the name from user string, or fall back to email or raw string.""" 
21+     # Match: "Name <[email protected] >"  22+     match  =  re .match (r"^(.*)<([^>]+)>$" , user )
23+     if  match :
24+         name  =  match .group (1 ).strip ()
25+         email  =  match .group (2 ).strip ()
26+         return  name  if  name  else  email 
27+     else :
28+         return  user .strip ()
29+ 
30+ 
1831def  format_summary_line (
1932    web_url : str , user : str , base : int , tip : int , branch : str , node : str 
2033) ->  str :
@@ -23,10 +36,11 @@ def format_summary_line(
2336    information about the changeset and links to the changelog if a 
2437    web URL has been configured: 
2538
26-     Jane Doe <[email protected] >  pushed 1 commit to default (170:e494a5be3393): 39+     Jane Doe pushed 1 commit to default (170:e494a5be3393): 
2740    """ 
2841    revcount  =  tip  -  base 
2942    plural  =  "s"  if  revcount  >  1  else  "" 
43+     display_user  =  parse_user (user )
3044
3145    if  web_url :
3246        shortlog_base_url  =  web_url .rstrip ("/" ) +  "/shortlog/" 
@@ -35,7 +49,7 @@ def format_summary_line(
3549    else :
3650        formatted_commit_count  =  f"{ revcount } { plural }  
3751
38-     return  f"**{ user } { formatted_commit_count } { branch } { tip } { node [:12 ]} \n \n " 
52+     return  f"**{ display_user } { formatted_commit_count } { branch } { tip } { node [:12 ]} \n \n " 
3953
4054
4155def  format_commit_lines (web_url : str , repo : repo , base : int , tip : int ) ->  str :
0 commit comments