GraphQL: How to get a list of commits between tags or releases #24779
-
I posted on StackOverflow as well: github-graphql-how-to-get-a-list-of-commits-between-tag If possible, I would like to make a single query that would give me the commit list between releases or tags. If only 1 tag were provided it would be the list from current master (latest commit) until that tag, and if 2 were provided it would be the list between the 2 tags. I wasn’t sure of the best way to approach this without using more than 1 query. In truth, I only need commits from master to the most recent tag or between tags next to one another if that makes it easier. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
This kind of query isn’t something that the GraphQL API is designed to be able to give you at this point. In theory, if you’re certain that For now, using git itself is probably the best way to get at the information you’re looking for. I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks @lee-dohm for the helpful response! In truth, I’m only ever concerned with the master branch, and reality is that I need to see a commit list from the last release to the current point in time, as a new release is about to be generated. So even if am just getting a list of commits up to the last tag, or list of commits up to the last release that would be enough. Is that possible with the “Release” or “Tag” and … on Commit fragment? I’m just learning GraphQl (first couple of days) so forgive the ignorance. Even if there was a way for me to list a bunch of commits, and discern that one of them was tagged, that would be enough, but I can’t seem to get that info just from “Commit” history. |
Beta Was this translation helpful? Give feedback.
-
So if you only want to get the list of commits from the
to get the information on the commit pointed to by the given tag (“v0.5.0” in my example). From there you could get the
by placing the I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
@lee-dohm This is truly helpful. I made it a little more dynamic by doing this:
Then I can use the createdAt you suggested in the same way and get my commit list since the last release. I really appreciate the help! It’s too bad I couldn’t do this all in a single query but it took me 3 requests with the v3 rest API so it’s still an improvement and the filtering logic is much easier now. Thank you! |
Beta Was this translation helpful? Give feedback.
-
You’re welcome 😀 One other thing to note is that you don’t need to do
I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
I’m curious how I would know what is the previous release. E.g. in one repo I have v1.1.0-beta3, v1.1.1, v1.1.0-beta4. Here’s the query (roughly):
Here’s the result:
|
Beta Was this translation helpful? Give feedback.
So if you only want to get the list of commits from the
HEAD
of themaster
branch back to some release tag, you could use this query:to get the information on the commit pointed to by the given tag (“v0.5.0” in my example). From there you could get the
committedDate
value to supply to this query: