Created
March 4, 2016 19:16
-
-
Save mattantonelli/fc4910156e5c42da4b53 to your computer and use it in GitHub Desktop.
Identifies the owners of all of a Github organization's private repos based on initial commits.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# | |
# Usage: ruby breakdown_repos.rb > repos.csv | |
# | |
require 'github_api' | |
BASIC_AUTH = 'username:personalaccesstoken' | |
ORG = 'myOrg' | |
github = Github.new(basic_auth: BASIC_AUTH, auto_pagination: true) | |
org_repos = github.repos.list(org: ORG) | |
private_repos = org_repos.select { |repo| repo[:private] } | |
user_repos = private_repos.each_with_object(Hash.new { |k, v| k[v] = Array.new }) do |repo, h| | |
user = github.repos.commits.list(ORG, repo.name)[-1].commit.author.email | |
h[user] << { name: repo.name, created_at: repo.created_at } | |
end | |
user_repos.each do |user, repos| | |
repos.each do |repo| | |
puts [user, *repo.values_at(:name, :created_at)].join(',') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment