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

Update summarize_release.py #193

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion utils/autolabel_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_github_data(endpoint: str) -> dict:

def get_event_content() -> Tuple[int, str, str, str]:
"""Extracts the number, title, body, and username from the issue or pull request."""
with open(GITHUB_EVENT_PATH, "r") as f:
with open(GITHUB_EVENT_PATH) as f:
event_data = json.load(f)

if GITHUB_EVENT_NAME == "issues":
Expand Down
7 changes: 6 additions & 1 deletion utils/summarize_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import subprocess
from datetime import datetime

import requests

Expand Down Expand Up @@ -78,9 +79,13 @@ def get_prs_between_tags(repo_name: str, previous_tag: str, latest_tag: str) ->
"body": remove_html_comments(pr_data["body"]),
"author": pr_data["user"]["login"],
"html_url": pr_data["html_url"],
"merged_at": pr_data["merged_at"],
}
)

# Sort PRs by merge date
prs.sort(key=lambda x: datetime.strptime(x["merged_at"], "%Y-%m-%dT%H:%M:%SZ"))

return prs


Expand All @@ -90,7 +95,7 @@ def generate_release_summary(diff: str, prs: list, latest_tag: str, previous_tag
[f"PR #{pr['number']}: {pr['title']} by @{pr['author']}\n{pr['body'][:1000]}..." for pr in prs]
)

current_pr = prs[0] if prs else None
current_pr = prs[-1] if prs else None
current_pr_summary = (
f"Current PR #{current_pr['number']}: {current_pr['title']} by @{current_pr['author']}\n{current_pr['body'][:1000]}..."
if current_pr
Expand Down
4 changes: 2 additions & 2 deletions utils/update_markdown_code_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def generate_temp_filename(file_path, index):
def process_markdown_file(file_path, temp_dir, verbose=False):
"""Reads a markdown file, extracts Python code blocks, saves them to temp files, and updates the file."""
try:
with open(file_path, "r") as file:
with open(file_path) as file:
markdown_content = file.read()

code_blocks = extract_code_blocks(markdown_content)
Expand Down Expand Up @@ -125,7 +125,7 @@ def update_markdown_file(file_path, markdown_content, temp_files):
"""Updates the markdown file with formatted code blocks."""
for num_spaces, original_code_block, temp_file_path in temp_files:
try:
with open(temp_file_path, "r") as temp_file:
with open(temp_file_path) as temp_file:
formatted_code = temp_file.read().rstrip("\n") # Strip trailing newlines
formatted_code_with_indentation = add_indentation(formatted_code, num_spaces)

Expand Down