Getting the highest PR number in a repo #131392
Replies: 1 comment
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
I've come across an interesting problem with the gh API. I would like to get the current maximum PR number for a repository. I want to do this because I want to cache locally all PR details, so I obviously want an efficient algorithm to check for 'new' PRs. The API provides no facility to order results by PR number, and by default orders by creation date. But the PR only gets 'created' when it stops being a draft, so one could create a PR with a given number, keep is as a draft for some time, then open it, and it will then appear first in the default enumeration order which is by creation date. If you want to then find out what really is the highest number you must continue the enumeration until it's complete, which could take some time. Or you could repetitively query for higher numbers than the one you have. Either way is inefficient, when you just want a single call to give you the maximum number. Did I miss some trick here?
Beta Was this translation helpful? Give feedback.
All reactions