From 8cdc02ecea92de14ac0a83441b871c0a864ada95 Mon Sep 17 00:00:00 2001 From: Can Bulut Bayburt Date: Wed, 27 Nov 2024 16:19:09 +0100 Subject: [PATCH] Get extended (untruncated) commit messages from GH API --- .github/workflows/changelogs/changelogs.py | 10 +++++++--- .github/workflows/changelogs/test_changelogs.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changelogs/changelogs.py b/.github/workflows/changelogs/changelogs.py index 60804fe27937..f3bcd52605dd 100644 --- a/.github/workflows/changelogs/changelogs.py +++ b/.github/workflows/changelogs/changelogs.py @@ -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""" diff --git a/.github/workflows/changelogs/test_changelogs.py b/.github/workflows/changelogs/test_changelogs.py index 18850503e48a..ce4e9ef7e28a 100644 --- a/.github/workflows/changelogs/test_changelogs.py +++ b/.github/workflows/changelogs/test_changelogs.py @@ -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.")