lib/site_hook/webhook.rb in site_hook-0.6.9 vs lib/site_hook/webhook.rb in site_hook-0.6.10

- old
+ new

@@ -94,22 +94,26 @@ halt 404, { 'Content-Type' => 'application/json' }, { message: 'no such project', status: 1 }.to_json end plaintext = false signature = nil event = nil + gogs = request.env.fetch('HTTP_X_GOGS_EVENT', nil) + unless gogs.nil? + event = 'push' if gogs == 'push' + end github = request.env.fetch('HTTP_X_GITHUB_EVENT', nil) unless github.nil? event = 'push' if github == 'push' end gitlab = request.env.fetch('HTTP_X_GITLAB_EVENT', nil) unless gitlab.nil? event = 'push' if gitlab == 'push' end - gogs = request.env.fetch('HTTP_X_GOGS_EVENT', nil) - unless gogs.nil? - event = 'push' if gogs == 'push' - end + events = { 'github' => github, 'gitlab' => gitlab, 'gogs' => gogs } + if events['github'] && events['gogs'] + events['github'] = nil + end events_m_e = events.values.one? case events_m_e when true event = 'push' service = events.select { |_key, value| value }.keys.first