summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-04-27 16:29:31 +0300
committerValery Sizov <vsv2711@gmail.com>2015-04-27 16:29:31 +0300
commitbc9ba5237cafd4b24405596f0c9e8af099635c29 (patch)
tree82ded5d3c0cbc39a9bfd0430684757d7309c9a88
parentbb8c1cadf39415d2f916d135e8bbfdce49842f2f (diff)
downloadgitlab-ce-bc9ba5237cafd4b24405596f0c9e8af099635c29.tar.gz
Revert "Added X-GitLab-Event header for web hooks"
This reverts commit 548f182814acd0f7a110e6c165c186e345901b00.
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/admin/hooks_controller.rb2
-rw-r--r--app/models/hooks/web_hook.rb16
-rw-r--r--app/models/project.rb2
-rw-r--r--app/services/system_hooks_service.rb6
-rw-r--r--app/services/test_hook_service.rb2
-rw-r--r--app/workers/project_web_hook_worker.rb4
-rw-r--r--app/workers/system_hook_worker.rb4
-rw-r--r--lib/api/system_hooks.rb2
-rw-r--r--spec/models/hooks/web_hook_spec.rb14
10 files changed, 21 insertions, 32 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 38dcb7dd227..97b8c182c42 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,7 +11,6 @@ v 7.11.0 (unreleased)
- Add "Reply quoting selected text" shortcut key (`r`)
- Fix bug causing `@whatever` inside an issue's first code block to be picked up as a user mention.
- Fix bug causing `@whatever` inside an inline code snippet (backtick-style) to be picked up as a user mention.
- - Added GitLab Event header for project hooks
-
- Show Atom feed buttons everywhere where applicable.
- Add project activity atom feed.
diff --git a/app/controllers/admin/hooks_controller.rb b/app/controllers/admin/hooks_controller.rb
index 690096bdbcf..0a463239d74 100644
--- a/app/controllers/admin/hooks_controller.rb
+++ b/app/controllers/admin/hooks_controller.rb
@@ -33,7 +33,7 @@ class Admin::HooksController < Admin::ApplicationController
owner_name: "Someone",
owner_email: "example@gitlabhq.com"
}
- @hook.execute(data, 'system_hooks')
+ @hook.execute(data)
redirect_to :back
end
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index e9fd441352d..315d96af1b9 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -30,15 +30,12 @@ class WebHook < ActiveRecord::Base
validates :url, presence: true,
format: { with: /\A#{URI.regexp(%w(http https))}\z/, message: "should be a valid url" }
- def execute(data, hook_name)
+ def execute(data)
parsed_url = URI.parse(url)
if parsed_url.userinfo.blank?
WebHook.post(url,
body: data.to_json,
- headers: {
- "Content-Type" => "application/json",
- "X-Gitlab-Event" => hook_name.singularize.titleize
- },
+ headers: { "Content-Type" => "application/json" },
verify: false)
else
post_url = url.gsub("#{parsed_url.userinfo}@", "")
@@ -48,10 +45,7 @@ class WebHook < ActiveRecord::Base
}
WebHook.post(post_url,
body: data.to_json,
- headers: {
- "Content-Type" => "application/json",
- "X-Gitlab-Event" => hook_name.singularize.titleize
- },
+ headers: { "Content-Type" => "application/json" },
verify: false,
basic_auth: auth)
end
@@ -60,7 +54,7 @@ class WebHook < ActiveRecord::Base
false
end
- def async_execute(data, hook_name)
- Sidekiq::Client.enqueue(ProjectWebHookWorker, id, data, hook_name)
+ def async_execute(data)
+ Sidekiq::Client.enqueue(ProjectWebHookWorker, id, data)
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 391c9ed6e9d..397232e98d8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -483,7 +483,7 @@ class Project < ActiveRecord::Base
def execute_hooks(data, hooks_scope = :push_hooks)
hooks.send(hooks_scope).each do |hook|
- hook.async_execute(data, hooks_scope.to_s)
+ hook.async_execute(data)
end
end
diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb
index 60235b6be2a..c5d0b08845b 100644
--- a/app/services/system_hooks_service.rb
+++ b/app/services/system_hooks_service.rb
@@ -7,12 +7,12 @@ class SystemHooksService
def execute_hooks(data)
SystemHook.all.each do |sh|
- async_execute_hook(sh, data, 'system_hooks')
+ async_execute_hook sh, data
end
end
- def async_execute_hook(hook, data, hook_name)
- Sidekiq::Client.enqueue(SystemHookWorker, hook.id, data, hook_name)
+ def async_execute_hook(hook, data)
+ Sidekiq::Client.enqueue(SystemHookWorker, hook.id, data)
end
def build_event_data(model, event)
diff --git a/app/services/test_hook_service.rb b/app/services/test_hook_service.rb
index e85e58751e7..21ec2c01cb8 100644
--- a/app/services/test_hook_service.rb
+++ b/app/services/test_hook_service.rb
@@ -1,6 +1,6 @@
class TestHookService
def execute(hook, current_user)
data = Gitlab::PushDataBuilder.build_sample(hook.project, current_user)
- hook.execute(data, 'push_hooks')
+ hook.execute(data)
end
end
diff --git a/app/workers/project_web_hook_worker.rb b/app/workers/project_web_hook_worker.rb
index fb878965288..73085c046bd 100644
--- a/app/workers/project_web_hook_worker.rb
+++ b/app/workers/project_web_hook_worker.rb
@@ -3,8 +3,8 @@ class ProjectWebHookWorker
sidekiq_options queue: :project_web_hook
- def perform(hook_id, data, hook_name)
+ def perform(hook_id, data)
data = data.with_indifferent_access
- WebHook.find(hook_id).execute(data, hook_name)
+ WebHook.find(hook_id).execute(data)
end
end
diff --git a/app/workers/system_hook_worker.rb b/app/workers/system_hook_worker.rb
index a122c274763..3ebc62b7e7a 100644
--- a/app/workers/system_hook_worker.rb
+++ b/app/workers/system_hook_worker.rb
@@ -3,7 +3,7 @@ class SystemHookWorker
sidekiq_options queue: :system_hook
- def perform(hook_id, data, hook_name)
- SystemHook.find(hook_id).execute(data, hook_name)
+ def perform(hook_id, data)
+ SystemHook.find(hook_id).execute data
end
end
diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb
index 22b8f90dc5c..518964db50d 100644
--- a/lib/api/system_hooks.rb
+++ b/lib/api/system_hooks.rb
@@ -47,7 +47,7 @@ module API
owner_name: "Someone",
owner_email: "example@gitlabhq.com"
}
- @hook.execute(data, 'system_hooks')
+ @hook.execute(data)
data
end
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index 14f873e6b5a..67ec9193ad7 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -52,26 +52,22 @@ describe ProjectHook do
end
it "POSTs to the web hook URL" do
- @project_hook.execute(@data, 'push_hooks')
- expect(WebMock).to have_requested(:post, @project_hook.url).
- with(headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Push Hook'}).
- once
+ @project_hook.execute(@data)
+ expect(WebMock).to have_requested(:post, @project_hook.url).once
end
it "POSTs the data as JSON" do
json = @data.to_json
- @project_hook.execute(@data, 'push_hooks')
- expect(WebMock).to have_requested(:post, @project_hook.url).
- with(headers: {'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'Push Hook'}).
- once
+ @project_hook.execute(@data)
+ expect(WebMock).to have_requested(:post, @project_hook.url).with(body: json).once
end
it "catches exceptions" do
expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
expect {
- @project_hook.execute(@data, 'push_hooks')
+ @project_hook.execute(@data)
}.to raise_error
end
end