class Fbe::Graph

def total_commits(owner, name, branch)

Returns:
  • (Integer) - The total number of commits in the branch

Parameters:
  • branch (String) -- The branch name (e.g., "master" or "main")
  • name (String) -- The repository name
  • owner (String) -- The repository owner (username or organization)
def total_commits(owner, name, branch)
  result = query(
    <<~GRAPHQL
      {
        repository(owner: "#{owner}", name: "#{name}") {
          ref(qualifiedName: "#{branch}") {
            target {
              ... on Commit {
                history {
                  totalCount
                }
              }
            }
          }
        }
      }
    GRAPHQL
  )
  result.repository.ref.target.history.total_count
end