Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
@banyan

This comment has been minimized.

Copy link
Owner Author

banyan commented Sep 26, 2013

With this pr, github/github-services#695 finally we can get pull_request_review_comment event as default.
But only update hook doesn't work as mentioed here.
If using Web UI, delete hook and create again it's work. but with octokit, delete and create doesn't work and anyhow I needed to pass events.
So this script is just using edit_hook and passed current all of default events of hipchat.

@rohitn

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.