Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: make make_release.py compatible with windows environment #2894

Merged
merged 4 commits into from
Oct 13, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_changelog(changelog_path: str) -> str:
Returns:
Data of the CHANGELOG
"""
with open(changelog_path) as fh:
with open(changelog_path, encoding="utf-8") as fh:
changelog = fh.read()
return changelog

Expand All @@ -178,7 +178,7 @@ def write_changelog(new_changelog: str, changelog_path: str) -> None:
new_changelog: Contents of the new CHANGELOG
changelog_path: Path where the CHANGELOG file is
"""
with open(changelog_path, "w") as fh:
with open(changelog_path, "w", encoding="utf-8") as fh:
fh.write(new_changelog)


Expand Down Expand Up @@ -253,7 +253,9 @@ def get_formatted_changes(git_tag: str) -> Tuple[str, str]:
for prefix in grouped:
for commit in grouped[prefix]:
output += f"- {prefix}: {commit['msg']}\n"
output_with_user += f"- {prefix}: {commit['msg']} by @{commit['author']}\n"
output_with_user += (
f"- {prefix}: {commit['msg']} by @{commit['author']}\n"
)

return output, output_with_user

Expand All @@ -267,7 +269,7 @@ def get_most_recent_git_tag() -> str:
"""
git_tag = str(
subprocess.check_output(
["git", "describe", "--abbrev=0"], stderr=subprocess.STDOUT
["git", "describe", "--tag", "--abbrev=0"], stderr=subprocess.STDOUT
)
).strip("'b\\n")
return git_tag
Expand Down Expand Up @@ -309,16 +311,20 @@ def get_git_commits_since_tag(git_tag: str) -> List[Change]:
Returns:
List of all changes since git_tag.
"""
commits = subprocess.check_output(
[
"git",
"--no-pager",
"log",
f"{git_tag}..HEAD",
'--pretty=format:"%H:::%s:::%aN"',
],
stderr=subprocess.STDOUT,
).decode("UTF-8").strip()
commits = (
subprocess.check_output(
[
"git",
"--no-pager",
"log",
f"{git_tag}..HEAD",
'--pretty=format:"%H:::%s:::%aN"',
],
stderr=subprocess.STDOUT,
)
.decode("UTF-8")
.strip()
)
lines = commits.splitlines()
authors = get_author_mapping(len(lines))
return [parse_commit_line(line, authors) for line in lines if line != ""]
Expand Down Expand Up @@ -349,10 +355,8 @@ def parse_commit_line(line: str, authors: Dict[str, str]) -> Change:

# Standardize
message.strip()
commit_hash = commit_hash.strip('"')
commit_hash = commit_hash.strip().strip('"\\')

if author.endswith('"'):
author = author[:-1]
author_login = authors[commit_hash]

prefix = prefix.strip()
Expand Down
Loading