From bb228dbcfbfb82b8162e9f9b181cc6624f4230fe Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 28 Apr 2026 11:15:43 -0700 Subject: [PATCH] Fix computing the maximum merged PR (#7127) Assisted-by: Antigravity with Gemini --- github_tools/check_dependent_pr.py | 6 +++++- github_tools/check_dependent_pr_test.py | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/github_tools/check_dependent_pr.py b/github_tools/check_dependent_pr.py index aef2e02d5e64..95b07d72dbf7 100755 --- a/github_tools/check_dependent_pr.py +++ b/github_tools/check_dependent_pr.py @@ -118,7 +118,11 @@ _QUERY_LABEL = """ _QUERY_MAX_MERGED_PR = """ { repository(owner: "carbon-language", name: "carbon-lang") { - pullRequests(states: MERGED, first: 1) { + pullRequests( + states: MERGED + orderBy: {field: CREATED_AT, direction: DESC} + first: 1 + ) { nodes { number } diff --git a/github_tools/check_dependent_pr_test.py b/github_tools/check_dependent_pr_test.py index 2ceddab7b163..528a14b12b44 100644 --- a/github_tools/check_dependent_pr_test.py +++ b/github_tools/check_dependent_pr_test.py @@ -499,6 +499,16 @@ class TestCheckDependentPR(unittest.TestCase): _OID2, "pending", "This PR has open dependencies: #1" ) + def test_query_max_merged_pr_explicit_orderBy_and_first_one(self) -> None: + self.assertIn( + "orderBy: {field: CREATED_AT, direction: DESC}", + check_dependent_pr._QUERY_MAX_MERGED_PR, + ) + self.assertIn( + "first: 1", + check_dependent_pr._QUERY_MAX_MERGED_PR, + ) + if __name__ == "__main__": unittest.main()