Skip to content

Commit

Permalink
fix release_notes script
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh committed Feb 10, 2023
1 parent 2c9456d commit f77c0e0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import os
from typing import List
from typing import List, Optional

import packaging.version

Expand Down Expand Up @@ -46,13 +46,15 @@ def get_change_log_notes() -> str:
def get_commit_history() -> str:
new_version = packaging.version.parse(TAG)

os.popen("git fetch --tags")

# Get all tags sorted by version, latest first.
all_tags = os.popen("git tag -l --sort=-version:refname 'v*'").read().split("\n")

# Out of `all_tags`, find the latest previous version so that we can collect all
# commits between that version and the new version we're about to publish.
# Note that we ignore pre-releases unless the new version is also a pre-release.
last_tag: str
last_tag: Optional[str] = None
for tag in all_tags:
if not tag.strip(): # could be blank line
continue
Expand All @@ -62,7 +64,10 @@ def get_commit_history() -> str:
if version < new_version:
last_tag = tag
break
commits = os.popen(f"git log {last_tag}..{TAG}^ --oneline --first-parent").read()
if last_tag is not None:
commits = os.popen(f"git log {last_tag}..{TAG}^ --oneline --first-parent").read()
else:
commits = os.popen(f"git log --oneline --first-parent").read()
return "## Commits\n\n" + commits


Expand Down

0 comments on commit f77c0e0

Please sign in to comment.