Last active
August 29, 2015 14:08
-
-
Save derekprior/c586686f831ca552ab84 to your computer and use it in GitHub Desktop.
Remove tenxer repository hooks from your organization's repositories. Requires octokit gem.
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
#!/usr/bin/env ruby | |
require "octokit" | |
if (ARGV.length < 1) | |
puts "You must supply a GitHub access token" | |
exit 1 | |
end | |
access_token = ARGV[0] | |
client = Octokit::Client.new(access_token: access_token) | |
client.auto_paginate = true | |
non_admin_repos = [] | |
client.organization_repositories("thoughtbot").each do |repo| | |
if repo.permissions.admin? | |
tenxer_hook = client.hooks(repo.full_name).detect do |hook| | |
hook.name == "tenxer" | |
end | |
if tenxer_hook | |
if client.remove_hook(repo.full_name, tenxer_hook.id) | |
puts "tenxer hook removed from #{repo.full_name}" | |
end | |
end | |
else | |
non_admin_repos << repo | |
end | |
end | |
puts "\n\nDon't have permission to check or clean these repos:" | |
non_admin_repos.each { |repo| puts repo.full_name } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment