Skip to content

Instantly share code, notes, and snippets.

@ches
Forked from banyan/update-hipchat-hooks-event.rb
Last active December 29, 2015 12:59
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 ches/7674132 to your computer and use it in GitHub Desktop.
Save ches/7674132 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'netrc'
require 'octokit'
org_name = ARGV[0]
unless org_name
abort "Usage #{$0} org_name"
end
octokit = Octokit::Client.new(netrc: true)
# https://github.com/github/github-services/blob/master/lib/services/hipchat.rb#L6-L8
events = %w(
commit_comment
download
fork
fork_apply
gollum
issues
issue_comment
member
public
pull_request
pull_request_review_comment
push
watch
)
# Make sure your org's repo size, the default of per_page is 30.
# If you org repos are over, it doesn't return else.
octokit.org_repos(org_name, :type => 'all', :per_page => 100).each do |repo|
slug = repo.full_name
begin
octokit.hooks(slug).each do |hook|
if hook.name == 'hipchat'
octokit.edit_hook(slug, hook.id, hook.name, hook.config.attrs, 'events' => events)
puts "updated: #{slug}"
end
end
rescue Octokit::NotFound
STDERR.puts "Warning: #$!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment