Skip to content

Instantly share code, notes, and snippets.

@nickmccurdy
Created July 18, 2013 00:43
Show Gist options
  • Save nickmccurdy/6025845 to your computer and use it in GitHub Desktop.
Save nickmccurdy/6025845 to your computer and use it in GitHub Desktop.
require 'octokit'
require 'colorize'
def create_logged_in_client
puts 'Logging into GitHub. Don\'t worry, I won\'t save your credentials.'
print 'GitHub username: '
username = $stdin.gets.strip
print 'GitHub password: '
password = begin
`stty -echo` rescue nil
$stdin.gets.strip
ensure
`stty echo` rescue nil
end
puts
client = Octokit::Client.new login: username, password: password
client.create_authorization({ scopes: ['public_repo', 'gist'] })
client
end
puts
client = create_logged_in_client
repos = client.repos.map { |repo| repo['full_name'] }
puts 'Searching for license files...'
repos.each do |repo|
print repo, '... '
files = client.contents repo
licensed = files.any? { |f| f['name'] == 'LICENSE.txt' }
puts licensed ? 'yes'.green : 'no'.red
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment