Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 2

GraphQL - list all branches by repository

Solved! Go to Solution.

Hi,

 

  The following query lists all the repo.

 

Is there any way to list branches and the last commit date?

 

{
  search(query: "org:udayabaski", type: REPOSITORY, last: 100) {
    edges {
      node {
        ... on  Repository{
          name
          url
          createdAt
          isArchived
          isDisabled
          updatedAt
          defaultBranchRef {
            name
          }
          branchProtectionRules(first:100) {
             edges {
              node {
                dismissesStaleReviews
              }
            }
          }
          collaborators(first:100) {
            totalCount
            edges {
              node {
                email
              }
            }
          }
          releases(first:10) {
            totalCount
            edges {
              node {
                author {
                  email
                }
                publishedAt
                tagName
                name
                isDraft
                isPrerelease
                tag {
                  id
                }
                tagName
              }
            }
          }
        }
      }
    }
  }
}
1 Reply
Solution
Community Manager
Message 2 of 2

Re: GraphQL - list all branches by repository

This query should give you the information that you're asking for:

 

{
  search(query: "org:udayabaski", type: REPOSITORY, last: 100) {
    nodes {
      ... on Repository {
        nameWithOwner
        refs(first: 100, refPrefix: "refs/heads/") {
          nodes {
            name
            target {
              ... on Commit {
                oid
                committedDate
              }
            }
          }
        }
      }
    }
  }
}

The thing to know is that branches are a type of ref (short for reference), something that refers to another object in the git database.

 

I hope that helps!