Last active
September 14, 2015 13:44
-
-
Save reu/b323f3bc0a7c5bc4ef7f to your computer and use it in GitHub Desktop.
Removes an user from all repositories of a Codeplane account
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
#!/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