@@ -88,11 +88,18 @@ def fetch_pr_info(pr_number: int) -> Optional[PrInfo]:
8888
8989
9090def get_commit_info (commit : Any ) -> CommitInfo :
91- match = re . match ( r"(.*) \(#(\d+)\)" , commit . summary )
92- if match :
91+ # Squash-merge commits:
92+ if match := re . match ( r"(.*) \(#(\d+)\)" , commit . summary ) :
9393 title = str (match .group (1 ))
9494 pr_number = int (match .group (2 ))
9595 return CommitInfo (hexsha = commit .hexsha , title = title , pr_number = pr_number )
96+
97+ # Normal merge commits:
98+ elif match := re .match (r"Merge pull request #(\d+) from (.*)" , commit .summary ):
99+ title = str (match .group (2 ))
100+ pr_number = int (match .group (1 ))
101+ return CommitInfo (hexsha = commit .hexsha , title = title , pr_number = pr_number )
102+
96103 else :
97104 return CommitInfo (hexsha = commit .hexsha , title = commit .summary , pr_number = None )
98105
@@ -111,7 +118,7 @@ def print_section(crate: str, items: list[str]) -> None:
111118 print ()
112119
113120
114- def commit_range (new_version : str ) -> str :
121+ def calc_commit_range (new_version : str ) -> str :
115122 parts = new_version .split ("." )
116123 assert len (parts ) == 3 , "Expected version to be on the format X.Y.Z"
117124 major = int (parts [0 ])
@@ -144,8 +151,10 @@ def main() -> None:
144151 parser .add_argument ("--version" , required = True , help = "The version of the new release, e.g. 0.42.0" )
145152 args = parser .parse_args ()
146153
154+ commit_range = calc_commit_range (args .version )
155+
147156 repo = Repo ("." )
148- commits = list (repo .iter_commits (commit_range ( args . version ) ))
157+ commits = list (repo .iter_commits (commit_range ))
149158 commits .reverse () # Most recent last
150159 commit_infos = list (map (get_commit_info , commits ))
151160
0 commit comments