How to list the last PR merged to a branch #2272
Replies: 1 comment 1 reply
-
Hi @abhimeht23! Thanks for opening this discussion. Your question is more related to what options GitHub API gives the users than how to make that REST/GraphQL API Request with Octokit. I think your question can be better addressed in GitHub Discussions: API and Webhooks. If you decide to post there, feel free to @mention me. I would be happy to track and give my input on it to help you discover this with GitHub Community. My quick researchTaking a quick look, I've found a way to get the last UPDATED Pull Request with the state But, to be the most recent Pull Request updated does not necessarily mean it is the most recent merged one (it can have a new comment or a new label after weeks of being merged, for example). Here's the GraphQL query I run in GitHub's GraphQL Explorer, in case it can be useful to you: query {
repository(owner: "oscard0m", name: "web") {
pullRequests(states: MERGED, first: 1, orderBy: { field: UPDATED_AT, direction: DESC }, baseRefName: "main") {
nodes {
title,
merged,
updatedAt,
mergedAt,
url,
headRefName,
baseRef {
name
}
}
}
}
} output{
"data": {
"repository": {
"pullRequests": {
"nodes": [
{
"title": "chore(deps): update dependency eslint to v8.21.0",
"merged": true,
"updatedAt": "2022-08-11T10:55:30Z",
"mergedAt": "2022-08-01T10:19:45Z",
"url": "https://github.com/oscard0m/web/pull/232",
"headRefName": "renovate/eslint-8.x",
"baseRef": {
"name": "main"
}
}
]
}
}
}
} As you can see, the |
Beta Was this translation helpful? Give feedback.
-
Hi @gr2m / @timrogers ,
Is there an API that gives detail of the last pull request that was merged to "main" or "master" branch? For my application I want to know the last pull request that was merged into master branch.
Thanks,
Abhi
Beta Was this translation helpful? Give feedback.
All reactions