2

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
  • This may not be possible via GraphQL, but in v3 it's straightforward: https://api.github.com/repos/CoolCompany/awesome-new-ui/compare/A...B where A and B are any git reference Commented Feb 12, 2020 at 8:13

1 Answer 1

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
          }
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.