Skip to content

Commit

Permalink
Get extended (untruncated) commit messages from GH API
Browse files Browse the repository at this point in the history
  • Loading branch information
cbbayburt committed Nov 28, 2024
1 parent 812782b commit 8cdc02e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/changelogs/changelogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,15 @@ def get_pr_trackers(self, git_repo: str, pr_number: int) -> dict[str, list[tuple
assert git_repo

logging.info(f"Requesting information for PR#{pr_number} at '{git_repo}'")
stream = os.popen(f'gh pr view -R {git_repo} {pr_number} --json title,commits -q ".title, .commits[].messageHeadline, .commits[].messageBody | select(length > 0)"')
commits = stream.read()

pr_path = f'repos/{git_repo}/pulls/{pr_number}'
stream = os.popen(f'gh api {pr_path} -q ".title" && gh api {pr_path}/commits -q ".[].commit.message | select(length > 0)"')
title_and_commits = stream.read()
if stream.close():
raise Exception("An error occurred when getting the PR information from the GitHub API.")
return self.extract_trackers(commits)

logging.debug(f"Retrieved title and commit messages for PR#{pr_number}:\n{title_and_commits}")
return self.extract_trackers(title_and_commits)

def validate_chlog_entry(self, entry: Entry) -> list[Issue]:
"""Validate a single changelog entry"""
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelogs/test_changelogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def gh_api_call(api_cmd):
First commit message (tckr#99)
Second commit message
"""
if re.search(r"^gh pr view -R [^ ]+ 999 .*", api_cmd):
if re.search(r"^gh api repos/[^/]*/[^/]*/pulls/999 .*", api_cmd):
return io.StringIO(pr_data)
else:
raise Exception("An error occurred when getting the PR information from the GitHub API.")
Expand Down

0 comments on commit 8cdc02e

Please sign in to comment.