问题
With Github GraphQL I want to answer the question:
What commits have been merged into master between releases/tags?
The result should be similar to the results for this question Get commit list between tags in Git if I were to do it on the command line.
I'm using the developer explorer and wondering if I will be able to do this with a single query or if I will need several. I tried the following but it does not give me the commits between tags that have not been tagged, just the tagged commits.
{
repository(owner: "CoolCompany", name: "awesome-new-ui") {
refs(refPrefix: "refs/tags/", first: 2, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) {
edges {
node {
id
name
target {
oid
... on Commit {
author {
date
email
name
}
message
}
}
}
}
}
}
}
回答1:
@lee-dohm from the Github GraphQL community helped me arrive at a solution which is posted here
I can paste my solution here as well. It seems this problem is not solve-able with a single query, but it can be done with 2 that work in conjunction with each other:
Step 1: Get the most recent release information. You could modify this for tags as well.
{
repository(owner: "CoolCompany", name: "awesome-ui") {
releases(last: 1) {
edges{
node{
tagName
createdAt
}
}
}
}
}
Step 2: Use the value from the createdAt (associated with the release or tag) and do this:
{
repository(owner: "CoolCompany", name: "awesome-ui") {
nameWithOwner
object(expression: "master") {
... on Commit {
oid
history(first: 100, since: "$createdAtDate") {
nodes {
oid
messageHeadline
author {
user {
login
}
}
committedDate
}
}
}
}
}
}
来源:https://stackoverflow.com/questions/56401516/github-graphql-how-to-get-a-list-of-commits-between-tags