Skip to content

Instantly share code, notes, and snippets.

@derekprior
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekprior/c586686f831ca552ab84 to your computer and use it in GitHub Desktop.
Save derekprior/c586686f831ca552ab84 to your computer and use it in GitHub Desktop.
Remove tenxer repository hooks from your organization's repositories. Requires octokit gem.
#!/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