Skip to content

Instantly share code, notes, and snippets.

@banyan
Last active December 24, 2015 00:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save banyan/6718410 to your computer and use it in GitHub Desktop.
Save banyan/6718410 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pit'
require 'octokit'
org_name = ARGV[0]
unless org_name
abort "Usage #{$0} org_name"
end
config = Pit.get('github', :require => {
'username' => 'Your user name of GitHub',
'password' => 'Your password of GitHub',
})
octokit = Octokit::Client.new(
login: config['username'],
password: config['password']
)
# 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
@rohitn
Copy link

rohitn commented Sep 27, 2013

@banyan Thanks a lot for this. On Octokit 2.2.0 I had to make this change:

octokit.edit_hook(slug, hook.id, hook.name, hook.config.attrs, 'events' => events)

@banyan
Copy link
Author

banyan commented Sep 29, 2013

@rohitn

Thanks for reporting. I had used very old version (octokit 1.21.0).
Updated the gist :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment