Last active
December 24, 2015 00:40
-
-
Save banyan/6718410 to your computer and use it in GitHub Desktop.
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 '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 |
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
@banyan Thanks a lot for this. On Octokit 2.2.0 I had to make this change: