Github GraphQl - How to get a list of commits between tags

给你一囗甜甜゛ 提交于 2021-01-29 08:52:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!