Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Created March 31, 2011 09:14
Show Gist options
  • Save timurvafin/896086 to your computer and use it in GitHub Desktop.
Save timurvafin/896086 to your computer and use it in GitHub Desktop.
Get list of private repos without commits more then 12 months
require 'rubygems'
require 'bundler/setup'
require 'octokit'
require 'active_support/core_ext'
@username = 'repo user name'
def client
@client ||= Octokit::Client.new(:login => 'login', :token => 'token')
end
def repositories
@repositories ||= client.repositories(@username, :private => true)
end
def expired?(repo, ttl = 12.month)
client.branches(repo).each do |branch|
if DateTime.now.to_i - client.commits(repo, branch.first, :page => 1).first.committed_date.to_datetime.to_i < ttl
return false
end
end
true
end
repositories.each do |repo|
puts repo.name if repo.private? && expired?(repo)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment