Class: HooksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/hooks_controller.rb

Constant Summary collapse

EVENT_HANDLERS =
{
  "pull_request" => Github::PullRequestEvent,
  "push" => Github::PostReceiveEvent,
  "commit_comment" => Github::CommitCommentEvent,
  "issue_comment" => Github::IssueCommentEvent,
  "pull_request_review_comment" => Github::DiffCommentEvent
}.freeze

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #api_authenticate!, #current_project, #expire_revision!, #followed_projects, #no_cache, #read_revision, #require_login, #return_or_cache_revision!, #revision, #save_current_project, #set_current_project, #unfurling?

Methods included from UrlHelper

#edit_release_path, #edit_release_url, #feature_path, #github_commit_range_url, #github_commit_url, #github_project_url, #github_url?, #goldmine_case_number_url, #link_to_project_feature, #new_release_url, #release_path, #release_url, #releases_path

Instance Method Details

#githubObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/hooks_controller.rb', line 13

def github
  event = request.headers["X-GitHub-Event"]

  if event == "ping"
    Rails.logger.info "\e[32m[github] ping received\e[0m"
    head 200

  elsif event_processor = EVENT_HANDLERS[event]
    payload = params.fetch "hook"
    event_processor.process! payload
    head 200

  else
    Rails.logger.warn "\e[33m[github] Unrecognized event: #{event}\e[0m"
    head 404
  end
end