@@ -165,7 +165,7 @@ def get_changelog(changelog_path: str) -> str:
165165 Returns:
166166 Data of the CHANGELOG
167167 """
168- with open (changelog_path ) as fh :
168+ with open (changelog_path , encoding = "utf-8" ) as fh :
169169 changelog = fh .read ()
170170 return changelog
171171
@@ -178,7 +178,7 @@ def write_changelog(new_changelog: str, changelog_path: str) -> None:
178178 new_changelog: Contents of the new CHANGELOG
179179 changelog_path: Path where the CHANGELOG file is
180180 """
181- with open (changelog_path , "w" ) as fh :
181+ with open (changelog_path , "w" , encoding = "utf-8" ) as fh :
182182 fh .write (new_changelog )
183183
184184
@@ -253,7 +253,9 @@ def get_formatted_changes(git_tag: str) -> Tuple[str, str]:
253253 for prefix in grouped :
254254 for commit in grouped [prefix ]:
255255 output += f"- { prefix } : { commit ['msg' ]} \n "
256- output_with_user += f"- { prefix } : { commit ['msg' ]} by @{ commit ['author' ]} \n "
256+ output_with_user += (
257+ f"- { prefix } : { commit ['msg' ]} by @{ commit ['author' ]} \n "
258+ )
257259
258260 return output , output_with_user
259261
@@ -267,7 +269,7 @@ def get_most_recent_git_tag() -> str:
267269 """
268270 git_tag = str (
269271 subprocess .check_output (
270- ["git" , "describe" , "--abbrev=0" ], stderr = subprocess .STDOUT
272+ ["git" , "describe" , "--tag" , "-- abbrev=0" ], stderr = subprocess .STDOUT
271273 )
272274 ).strip ("'b\\ n" )
273275 return git_tag
@@ -309,16 +311,20 @@ def get_git_commits_since_tag(git_tag: str) -> List[Change]:
309311 Returns:
310312 List of all changes since git_tag.
311313 """
312- commits = subprocess .check_output (
313- [
314- "git" ,
315- "--no-pager" ,
316- "log" ,
317- f"{ git_tag } ..HEAD" ,
318- '--pretty=format:"%H:::%s:::%aN"' ,
319- ],
320- stderr = subprocess .STDOUT ,
321- ).decode ("UTF-8" ).strip ()
314+ commits = (
315+ subprocess .check_output (
316+ [
317+ "git" ,
318+ "--no-pager" ,
319+ "log" ,
320+ f"{ git_tag } ..HEAD" ,
321+ '--pretty=format:"%H:::%s:::%aN"' ,
322+ ],
323+ stderr = subprocess .STDOUT ,
324+ )
325+ .decode ("UTF-8" )
326+ .strip ()
327+ )
322328 lines = commits .splitlines ()
323329 authors = get_author_mapping (len (lines ))
324330 return [parse_commit_line (line , authors ) for line in lines if line != "" ]
@@ -337,7 +343,7 @@ def parse_commit_line(line: str, authors: Dict[str, str]) -> Change:
337343 Raises:
338344 ValueError: The commit line is not well-structured
339345 """
340- parts = line .split (":::" )
346+ parts = line .strip (). strip ( '" \\ ' ). split (":::" )
341347 if len (parts ) != 3 :
342348 raise ValueError (f"Invalid commit line: '{ line } '" )
343349 commit_hash , rest , author = parts
@@ -349,10 +355,8 @@ def parse_commit_line(line: str, authors: Dict[str, str]) -> Change:
349355
350356 # Standardize
351357 message .strip ()
352- commit_hash = commit_hash .strip ('"' )
358+ commit_hash = commit_hash .strip ()
353359
354- if author .endswith ('"' ):
355- author = author [:- 1 ]
356360 author_login = authors [commit_hash ]
357361
358362 prefix = prefix .strip ()
0 commit comments