Created
June 27, 2013 15:53
-
-
Save fuzzmonkey/5877651 to your computer and use it in GitHub Desktop.
a script for find .ruby-version or .rbenv-version files in your github repos.
This file contains hidden or 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
| # Find any ruby-version or rbenv-version files in your GitHub repos | |
| # | |
| # usage: $ USERNAME=yourusername PASSWORD=yourpassword ruby ruby_version_find.rb | |
| # or | |
| # usage: $ USERNAME=yourusername PASSWORD=yourpassword ORG=yourorgname ruby ruby_version_find.rb | |
| # | |
| # n.b requires the octokit gem | |
| require 'rubygems' | |
| require 'octokit' | |
| USERNAME = ENV['USERNAME'] | |
| PASSWORD = ENV['PASSWORD'] | |
| ORG = ENV['ORG'] | |
| client = Octokit::Client.new(:login => USERNAME, :password => PASSWORD, :auto_traversal => true) | |
| if !ORG.nil? | |
| repos = client.org_repos(ORG) | |
| else | |
| repos = client.repos | |
| end | |
| versions = [] | |
| repos.each do |repo| | |
| puts '' | |
| puts repo.full_name | |
| begin | |
| rbenv_version = client.contents(repo.full_name, :path => '.rbenv-version') rescue nil | |
| ruby_version = client.contents(repo.full_name, :path => '.ruby-version') rescue nil | |
| if rbenv_version || ruby_version | |
| rbenv_content = rbenv_version ? Base64.decode64(rbenv_version.content) : nil | |
| ruby_content = ruby_version ? Base64.decode64(ruby_version.content) : nil | |
| versions << [repo.full_name, "#{rbenv_content || ruby_content}"] | |
| end | |
| rescue => e | |
| puts e.message | |
| end | |
| end | |
| versions.each do |version| | |
| puts "#{version[0]}: #{version[1]}" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment