From bdbc7ac73b1fc372fd4f11b5e341090f3b630a6d Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Wed, 29 May 2024 16:31:50 +0200 Subject: [PATCH 1/2] Fix requested files limit by using grapghql command Only write in file when PRs list is not empty in each category --- update_changelog.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/update_changelog.py b/update_changelog.py index 57a3c89355..917ddd00a0 100644 --- a/update_changelog.py +++ b/update_changelog.py @@ -58,13 +58,19 @@ def append_to_file(ctgr_name, prs, out_file): pr_url_cmd = "gh pr view {} --json url".format(pr) url = dict(json.loads(subprocess_run(*pr_url_cmd.split()).decode("utf-8")))["url"] # Files - pr_files_cmd = "gh pr view {} --json files".format(pr) - files = dict(json.loads(subprocess_run(*pr_files_cmd.split()).decode("utf-8")))["files"] + # Use a different command with graphql allowing pagination + # (since number of files retrieved with 'gh pr view {pr} files' is limited to 100) + # cf. https://github.com/cli/cli/issues/5368 + graphql_files_cmd = f"gh api graphql -f query='query($owner: String!, $repo: String!, $pr: Int!, $endCursor: String) {{repository(owner: $owner, name: $repo) {{pullRequest(number: $pr) {{files(first: 100, after: $endCursor) {{pageInfo{{ hasNextPage, endCursor }} nodes {{path}}}}}}}}}}' -F owner='mamba-org' -F repo='mamba' -F pr={pr} --paginate --jq '.data.repository.pullRequest.files.nodes.[].path'" + files = subprocess.run( + graphql_files_cmd, shell=True, capture_output=True, text=True + ).stdout.split("\n") + ref_mamba_pkgs = ["libmamba/", "libmambapy/", "micromamba/"] concerned_pkgs = set() for f in files: for ref_pkg in ref_mamba_pkgs: - if f["path"].startswith(ref_pkg): + if f.startswith(ref_pkg): concerned_pkgs.add(ref_pkg) if (sorted(ref_mamba_pkgs) == sorted(concerned_pkgs)) or (len(concerned_pkgs) == 0): @@ -145,9 +151,12 @@ def main(): "\nReleases: libmamba {0}, libmambapy {0}, micromamba {0}\n".format(release_version) ) # PRs info - append_to_file("Enhancements", enhancements_prs, changelog_file) - append_to_file("Bug fixes", bug_fixes_prs, changelog_file) - append_to_file("CI fixes and doc", ci_docs_prs, changelog_file) + if enhancements_prs: + append_to_file("Enhancements", enhancements_prs, changelog_file) + if bug_fixes_prs: + append_to_file("Bug fixes", bug_fixes_prs, changelog_file) + if ci_docs_prs: + append_to_file("CI fixes and doc", ci_docs_prs, changelog_file) # Write back old content of CHANGELOG file changelog_file.write("\n" + content_to_restore) From 5fa477ddea5964ef57e982116f45bff070772fdf Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Wed, 29 May 2024 17:23:03 +0200 Subject: [PATCH 2/2] Fix regex expression --- releaser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releaser.py b/releaser.py index 273ba8c674..6ddc5c16cf 100644 --- a/releaser.py +++ b/releaser.py @@ -126,7 +126,7 @@ def main(): release_start = idx + 1 break - brackets_re = re.compile(r"\[(.*)\]") + brackets_re = re.compile(r"\[(.*?)\]") # section with groups, heading + items sections = []