Pull commit totals across repos. How to handle if it is a master or main branch?

Hello, the below works. I can set it up so I can parameterize name and owner.

Not all repos have a master, some have a main. How can I structure this ref(qualifiedName: "master") to check for either and use that?

{
  repository(name: "spinnaker", owner: "spinnaker") {
    ref(qualifiedName: "master") {
      target {
        ... on Commit {
          history(first: 1) {
            edges {
              node {
                committedDate
              }
            }
            totalCount
          }
        }
      }
    }
  }
}

:wave: Welcome!

If you’re looking for the default branch, you can use defaultBranchRef

{
  repository(name: "spinnaker", owner: "spinnaker") {
     defaultBranchRef {
      name
      target {
        ... on Commit {
          history(first: 1) {
            edges {
              node {
                committedDate
              }
            }
            totalCount
          }
        }
      }
    }
  }
}
2 Likes

This post was flagged by the community and is temporarily hidden.