Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Created January 13, 2012 12:38
Show Gist options
  • Save timurvafin/1605908 to your computer and use it in GitHub Desktop.
Save timurvafin/1605908 to your computer and use it in GitHub Desktop.
List github repos without commits more then 1 year
source 'http://rubygems.org'
gem 'i18n'
gem 'activesupport', '>= 2.3.5'
gem 'octokit', '~> 0.6.0'
require 'rubygems'
require 'bundler/setup'
require 'octokit'
require 'active_support/core_ext'
USERNAME = ''
LOGIN = ''
TOKEN = ''
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