Skip to content

Commit

Permalink
Update summarize_release.py for initial releases (#367)
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
  • Loading branch information
glenn-jocher and UltralyticsAssistant authored Jan 16, 2025
1 parent fdb09ff commit 971c219
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion actions/__init__.py
Original file line number Diff line number Diff line change
@@ -22,4 +22,4 @@
# ├── test_summarize_pr.py
# └── ...

__version__ = "0.0.40"
__version__ = "0.0.41"
17 changes: 11 additions & 6 deletions actions/summarize_release.py
Original file line number Diff line number Diff line change
@@ -146,13 +146,15 @@ def create_github_release(repo_name: str, tag_name: str, name: str, body: str, h


def get_previous_tag() -> str:
"""Retrieves the previous Git tag, excluding the current tag, using the git describe command."""
cmd = ["git", "describe", "--tags", "--abbrev=0", "--exclude", CURRENT_TAG]
"""Returns previous Git tag or initial commit SHA if no tags exist."""
try:
# Try to get previous tag first
cmd = ["git", "describe", "--tags", "--abbrev=0", "--exclude", CURRENT_TAG]
return subprocess.run(cmd, check=True, text=True, capture_output=True).stdout.strip()
except subprocess.CalledProcessError:
print("Failed to get previous tag from git. Using previous commit.")
return "HEAD~1"
# If no tags exist, get the initial commit SHA
cmd = ["git", "rev-list", "--max-parents=0", "HEAD"]
return subprocess.run(cmd, check=True, text=True, capture_output=True).stdout.strip()


def main(*args, **kwargs):
@@ -162,9 +164,12 @@ def main(*args, **kwargs):
if not all([action.token, CURRENT_TAG]):
raise ValueError("One or more required environment variables are missing.")

previous_tag = PREVIOUS_TAG or get_previous_tag()

# Get the diff between the tags
previous_tag = (
PREVIOUS_TAG
if PREVIOUS_TAG and "none" not in PREVIOUS_TAG.lower() and PREVIOUS_TAG != CURRENT_TAG
else get_previous_tag()
)
diff = get_release_diff(action.repository, previous_tag, CURRENT_TAG, action.headers_diff)

# Get PRs merged between the tags

0 comments on commit 971c219

Please sign in to comment.