Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
d7fa9952
Commit
d7fa9952
authored
Dec 04, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'prevent-500-test-webhook' into 'master'
Prevent 500 test webhook Fixes #1803 See merge request !1299
parents
e1f1e062
db2edff9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
app/controllers/projects/hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+1
-0
app/models/hooks/web_hook.rb
app/models/hooks/web_hook.rb
+7
-1
app/services/test_hook_service.rb
app/services/test_hook_service.rb
+0
-3
No files found.
app/controllers/projects/hooks_controller.rb
View file @
d7fa9952
...
...
@@ -26,6 +26,7 @@ class Projects::HooksController < Projects::ApplicationController
def
test
if
!
@project
.
empty_repo?
status
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
if
status
flash
[
:notice
]
=
'Hook successfully executed.'
else
...
...
app/models/hooks/web_hook.rb
View file @
d7fa9952
...
...
@@ -32,7 +32,10 @@ class WebHook < ActiveRecord::Base
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"
},
verify:
false
)
WebHook
.
post
(
url
,
body:
data
.
to_json
,
headers:
{
"Content-Type"
=>
"application/json"
},
verify:
false
)
else
post_url
=
url
.
gsub
(
"
#{
parsed_url
.
userinfo
}
@"
,
""
)
auth
=
{
...
...
@@ -45,6 +48,9 @@ class WebHook < ActiveRecord::Base
verify:
false
,
basic_auth:
auth
)
end
rescue
SocketError
,
Errno
::
ECONNREFUSED
=>
e
logger
.
error
(
"WebHook Error =>
#{
e
}
"
)
false
end
def
async_execute
(
data
)
...
...
app/services/test_hook_service.rb
View file @
d7fa9952
...
...
@@ -2,8 +2,5 @@ class TestHookService
def
execute
(
hook
,
current_user
)
data
=
GitPushService
.
new
.
sample_data
(
hook
.
project
,
current_user
)
hook
.
execute
(
data
)
true
rescue
SocketError
false
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment