Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
nexedi
gitlab-shell
Commits
79558da9
Commit
79558da9
authored
Nov 16, 2016
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add instrumentation to push hooks
Related to #22053
parent
ed59fbc3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
lib/gitlab_access.rb
lib/gitlab_access.rb
+4
-1
lib/gitlab_custom_hook.rb
lib/gitlab_custom_hook.rb
+4
-3
lib/gitlab_post_receive.rb
lib/gitlab_post_receive.rb
+7
-2
No files found.
lib/gitlab_access.rb
View file @
79558da9
...
@@ -2,6 +2,7 @@ require_relative 'gitlab_init'
...
@@ -2,6 +2,7 @@ require_relative 'gitlab_init'
require_relative
'gitlab_net'
require_relative
'gitlab_net'
require_relative
'gitlab_access_status'
require_relative
'gitlab_access_status'
require_relative
'names_helper'
require_relative
'names_helper'
require_relative
'gitlab_metrics'
require
'json'
require
'json'
class
GitlabAccess
class
GitlabAccess
...
@@ -20,7 +21,9 @@ class GitlabAccess
...
@@ -20,7 +21,9 @@ class GitlabAccess
end
end
def
exec
def
exec
status
=
api
.
check_access
(
'git-receive-pack'
,
@repo_path
,
@actor
,
@changes
,
@protocol
)
status
=
GitlabMetrics
.
measure
(
'check-access:git-receive-pack'
)
do
api
.
check_access
(
'git-receive-pack'
,
@repo_path
,
@actor
,
@changes
,
@protocol
)
end
raise
AccessDeniedError
,
status
.
message
unless
status
.
allowed?
raise
AccessDeniedError
,
status
.
message
unless
status
.
allowed?
...
...
lib/gitlab_custom_hook.rb
View file @
79558da9
require
'open3'
require
'open3'
require_relative
'gitlab_metrics'
class
GitlabCustomHook
class
GitlabCustomHook
attr_reader
:vars
attr_reader
:vars
...
@@ -11,21 +12,21 @@ class GitlabCustomHook
...
@@ -11,21 +12,21 @@ class GitlabCustomHook
hook
=
hook_file
(
'pre-receive'
,
repo_path
)
hook
=
hook_file
(
'pre-receive'
,
repo_path
)
return
true
if
hook
.
nil?
return
true
if
hook
.
nil?
call_receive_hook
(
hook
,
changes
)
GitlabMetrics
.
measure
(
"pre-receive-hook"
)
{
call_receive_hook
(
hook
,
changes
)
}
end
end
def
post_receive
(
changes
,
repo_path
)
def
post_receive
(
changes
,
repo_path
)
hook
=
hook_file
(
'post-receive'
,
repo_path
)
hook
=
hook_file
(
'post-receive'
,
repo_path
)
return
true
if
hook
.
nil?
return
true
if
hook
.
nil?
call_receive_hook
(
hook
,
changes
)
GitlabMetrics
.
measure
(
"post-receive-hook"
)
{
call_receive_hook
(
hook
,
changes
)
}
end
end
def
update
(
ref_name
,
old_value
,
new_value
,
repo_path
)
def
update
(
ref_name
,
old_value
,
new_value
,
repo_path
)
hook
=
hook_file
(
'update'
,
repo_path
)
hook
=
hook_file
(
'update'
,
repo_path
)
return
true
if
hook
.
nil?
return
true
if
hook
.
nil?
system
(
vars
,
hook
,
ref_name
,
old_value
,
new_value
)
GitlabMetrics
.
measure
(
"update-hook"
)
{
system
(
vars
,
hook
,
ref_name
,
old_value
,
new_value
)
}
end
end
private
private
...
...
lib/gitlab_post_receive.rb
View file @
79558da9
require_relative
'gitlab_init'
require_relative
'gitlab_init'
require_relative
'gitlab_net'
require_relative
'gitlab_net'
require_relative
'gitlab_reference_counter'
require_relative
'gitlab_reference_counter'
require_relative
'gitlab_metrics'
require
'json'
require
'json'
require
'base64'
require
'base64'
require
'securerandom'
require
'securerandom'
...
@@ -21,14 +22,18 @@ class GitlabPostReceive
...
@@ -21,14 +22,18 @@ class GitlabPostReceive
result
=
update_redis
result
=
update_redis
begin
begin
broadcast_message
=
api
.
broadcast_message
broadcast_message
=
GitlabMetrics
.
measure
(
"broadcast-message"
)
do
api
.
broadcast_message
end
if
broadcast_message
.
has_key?
(
"message"
)
if
broadcast_message
.
has_key?
(
"message"
)
puts
puts
print_broadcast_message
(
broadcast_message
[
"message"
])
print_broadcast_message
(
broadcast_message
[
"message"
])
end
end
merge_request_urls
=
api
.
merge_request_urls
(
@repo_path
,
@changes
)
merge_request_urls
=
GitlabMetrics
.
measure
(
"merge-request-urls"
)
do
api
.
merge_request_urls
(
@repo_path
,
@changes
)
end
print_merge_request_links
(
merge_request_urls
)
print_merge_request_links
(
merge_request_urls
)
rescue
GitlabNet
::
ApiUnreachableError
rescue
GitlabNet
::
ApiUnreachableError
nil
nil
...
...
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