66# `hg push`). See https://zulip.com/integrations for installation instructions.
77
88import sys
9+ from email .utils import parseaddr
910
1011from mercurial import repository as repo
1112from mercurial import ui
1516VERSION = "0.9"
1617
1718
19+ def parse_user (user : str ) -> str :
20+ """
21+ Extract the name from user string, or fall back to email or raw string
22+ if the user string is not in the form "Jane Doe <email@example.com>".
23+ """
24+ name , email = parseaddr (user )
25+ return name or email or user .strip ()
26+
27+
1828def format_summary_line (
1929 web_url : str , user : str , base : int , tip : int , branch : str , node : str
2030) -> str :
@@ -23,10 +33,11 @@ def format_summary_line(
2333 information about the changeset and links to the changelog if a
2434 web URL has been configured:
2535
26- Jane Doe <jane@example.com> pushed 1 commit to default (170:e494a5be3393):
36+ Jane Doe pushed 1 commit to default (170:e494a5be3393):
2737 """
2838 revcount = tip - base
2939 plural = "s" if revcount > 1 else ""
40+ display_user = parse_user (user )
3041
3142 if web_url :
3243 shortlog_base_url = web_url .rstrip ("/" ) + "/shortlog/"
@@ -35,7 +46,7 @@ def format_summary_line(
3546 else :
3647 formatted_commit_count = f"{ revcount } commit{ plural } "
3748
38- return f"**{ user } ** pushed { formatted_commit_count } to **{ branch } ** (`{ tip } :{ node [:12 ]} `):\n \n "
49+ return f"**{ display_user } ** pushed { formatted_commit_count } to **{ branch } ** (`{ tip } :{ node [:12 ]} `):\n \n "
3950
4051
4152def format_commit_lines (web_url : str , repo : repo , base : int , tip : int ) -> str :
0 commit comments