Branches on Repository


#1

Hey!

I find only protectBranches for repository, but where is branches?

Thank


#2

Hi @ovr – great question!

As @davidcelis mentioned in https://platform.github.community/t/how-to-fetch-commits-from-repos/643:

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.

Here’s an example GraphQL query that fetches your ovr/phpsa's repository’s branches:

{
	repository(owner:"ovr", name:"phpsa") {
    refs(first: 10, refPrefix:"refs/heads/") {
      edges {
        node {
          name
        }
      }
    }
  }
}

Output:

{
  "data": {
    "repository": {
      "refs": {
        "edges": [
          {
            "node": {
              "name": "after-compile-events"
            }
          },
          {
            "node": {
              "name": "analyze-pass"
            }
          },
          {
            "node": {
              "name": "fork-threads"
            }
          },
          {
            "node": {
              "name": "master"
            }
          },
          {
            "node": {
              "name": "multi-thread"
            }
          },
          {
            "node": {
              "name": "pthreads"
            }
          }
        ]
      }
    }
  }
}

Hope that helps!


#3

Thank you @francisfuzz :beers: