How to fetch commits from repos?


#1
https://developer.github.com/v3/repos/commits

any possibility to grab these data ?

https://developer.github.com/early-access/graphql/object/ref

https://developer.github.com/v3/repos/branches/

what is this “ref” ? how to use it to get git tree, branch and commits


#2

A “ref” (short for reference) is anything that points to a git commit. This could be a local branch, a tag, a remote branch, etc. So master, for example, would be considered a ref. In that vein, you can use the ref field on the Repository type to get a reference that targets a commit. From that commit, you can get all of the commit’s parents. If you target master, you can get the main history of the git repository. For example:

query {
  node(id: "MDEwOlJlcG9zaXRvcnk4NDM5MTQ3") {
    ... on Repository {
      ref(qualifiedName: "master") {
        target {
          ... on Commit {
            id
            history(first: 30) {
              totalCount
              pageInfo {
                hasNextPage
              }

              edges {
                node {
                  oid
                  message
                  author {
                    name
                    email
                    date
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

That query would get the master ref and the commit it targets. From that commit, you’d get the most recent 30 commits in the master branch’s history, as well as author information for each commit and whether or not you’ll need to page through more.


Commit on repository
#3

thanks @davidcelis

after search branches in github graphiql docs, there’s no info at all, is that a unsupported feature for now ?


#4

How can we use graphql to fetch details about a certain commit in a given branch with giving the commit hash?