Get the time a commit was pushed? #24730
-
Using this API I can list the commits on a Pull Request: As far as I understand, the However when I look at a Pull Request on GItHub I can see information on push times: Is there some way to get this information via the API to reconstruct the PR timeline from the perspective of the reviewer? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
It’s available from the repository’s events api: You might be able to find an equivalent in GraphQL as well:
So, I’m trying to switch my small project from REST to GraphQL. Looks nice to fetch exactly what’s needed. But what I’m mostly fetching from REST are events from v3 but i can’t find it on the v4-docs. Is there any equivalent to events on GraphQL? |
Beta Was this translation helpful? Give feedback.
-
Thanks! Can the events API be queried by event type or filtered in any meaningful way? It doesn’t seem efficient to page through all repo events until I find the particular SHA I am looking for. |
Beta Was this translation helpful? Give feedback.
-
Dunno. In general if you want filtering you’re supposed to use GraphQL. I’m not a GraphQL expert. It’s sometimes powerful, although its power varies significantly depending on how the APIs are written. I practice, I’m definitely a pessimist. If I were you, I’d contact: And describe what you’re trying to do, having looked through both APIs and determined that they do not have an efficient way of retrieving the necessary information (obviously you get to do this step first). |
Beta Was this translation helpful? Give feedback.
-
Doesn’t look like this is possible in the REST API but it is possible using GQL, for example:
|
Beta Was this translation helpful? Give feedback.
-
A given commit can be pushed to multiple (related) repositories at different time points. Since a PR from a related PR likely contains a commit that has yet to be pushed into your repository, it’s correct to have a null If you asked the repository where the commit id does exist, GitHub should be able to tell you when it was pushed into that repository. |
Beta Was this translation helpful? Give feedback.
-
Ah I see, thanks! That gets a bit tricky with permissions I assume but good to know. |
Beta Was this translation helpful? Give feedback.
-
I don’t think you’ll run into permissions. If a repository is in your fork network, then you can see it, and if you can see it, then I’m pretty sure you can see when the commit was pushed. I could be wrong. You will of course have to pay for extra API hits. But you could construct a GQL query that combines a bunch of those lookups. |
Beta Was this translation helpful? Give feedback.
-
For finding a specific commit I'd also have a look at: https://www.gharchive.org a bit more chatter at: https://stackoverflow.com/a/78966680/895245 Not sure it's actually possible there though. |
Beta Was this translation helpful? Give feedback.
Doesn’t look like this is possible in the REST API but it is possible using GQL, for example:
pushedDate
will benull
in the case where the PR is from a fork, it looks like that information is just not available in that case.