Skip to content

Instantly share code, notes, and snippets.

@reu
Last active September 14, 2015 13:44
Show Gist options
  • Save reu/b323f3bc0a7c5bc4ef7f to your computer and use it in GitHub Desktop.
Save reu/b323f3bc0a7c5bc4ef7f to your computer and use it in GitHub Desktop.
Removes an user from all repositories of a Codeplane account
#!/usr/bin/env ruby
require "rubygems"
require "codeplane"
require "optparse"
Codeplane.configure do |config|
ARGV.options do |opts|
opts.on("-u", "--user=username", String) { |val| config.username = val }
opts.on("-p", "--api-key=key", String) { |val| config.api_key = val }
opts.parse!
end
end
email = ARGV.last
cp = Codeplane::Client.new
total = cp.repositories.count do |repository|
begin
repository.collaborators.remove(email)
puts "Removing from #{repository.name}"
true
rescue Codeplane::NotFoundError
false
end
end
puts "The user #{email} was removed from #{total} repositories"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment