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