Skip to content

Instantly share code, notes, and snippets.

@sskylar
Created December 20, 2017 20:59
Show Gist options
  • Save sskylar/e3227725119b862082fdc08e4b38c096 to your computer and use it in GitHub Desktop.
Save sskylar/e3227725119b862082fdc08e4b38c096 to your computer and use it in GitHub Desktop.
Count commits to all repos in GitHub over the past year
require 'octokit'
access_token = '<your token here>'
whitelist_owners = %w(dropmark siteleaf oakstudios)
Octokit.auto_paginate = true
client = Octokit::Client.new access_token: access_token
total = client.repos.map do |repo|
if !repo.fork && whitelist_owners.include?(repo.owner.login)
count = client.commit_activity_stats(repo.full_name, {retry_timeout: 60, retry_wait: 1}).map(&:total).reduce(:+)
puts "#{repo.full_name},#{count}"
count
else
0
end
end.reduce(:+)
puts "Total: #{total}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment