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
b98d59ac
Commit
b98d59ac
authored
Feb 05, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add gitaly notification on post-receive hook
parent
f61bdfe3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
lib/gitlab_net.rb
lib/gitlab_net.rb
+8
-0
lib/gitlab_post_receive.rb
lib/gitlab_post_receive.rb
+2
-0
spec/gitlab_post_receive_spec.rb
spec/gitlab_post_receive_spec.rb
+10
-0
No files found.
lib/gitlab_net.rb
View file @
b98d59ac
...
@@ -93,6 +93,14 @@ class GitlabNet
...
@@ -93,6 +93,14 @@ class GitlabNet
{}
{}
end
end
def
notify_post_receive
(
repo_path
)
resp
=
post
(
"
#{
host
}
/notify_post_receive"
,
repo_path:
repo_path
)
resp
.
code
==
'200'
rescue
false
end
def
redis_client
def
redis_client
redis_config
=
config
.
redis
redis_config
=
config
.
redis
database
=
redis_config
[
'database'
]
||
0
database
=
redis_config
[
'database'
]
||
0
...
...
lib/gitlab_post_receive.rb
View file @
b98d59ac
...
@@ -35,6 +35,8 @@ class GitlabPostReceive
...
@@ -35,6 +35,8 @@ class GitlabPostReceive
api
.
merge_request_urls
(
@repo_path
,
@changes
)
api
.
merge_request_urls
(
@repo_path
,
@changes
)
end
end
print_merge_request_links
(
merge_request_urls
)
print_merge_request_links
(
merge_request_urls
)
api
.
notify_post_receive
(
repo_path
)
rescue
GitlabNet
::
ApiUnreachableError
rescue
GitlabNet
::
ApiUnreachableError
nil
nil
end
end
...
...
spec/gitlab_post_receive_spec.rb
View file @
b98d59ac
...
@@ -19,6 +19,7 @@ describe GitlabPostReceive do
...
@@ -19,6 +19,7 @@ describe GitlabPostReceive do
GitlabConfig
.
any_instance
.
stub
(
repos_path:
repository_path
)
GitlabConfig
.
any_instance
.
stub
(
repos_path:
repository_path
)
GitlabNet
.
any_instance
.
stub
(
broadcast_message:
{
})
GitlabNet
.
any_instance
.
stub
(
broadcast_message:
{
})
GitlabNet
.
any_instance
.
stub
(
:merge_request_urls
).
with
(
repo_path
,
wrongly_encoded_changes
)
{
[]
}
GitlabNet
.
any_instance
.
stub
(
:merge_request_urls
).
with
(
repo_path
,
wrongly_encoded_changes
)
{
[]
}
GitlabNet
.
any_instance
.
stub
(
notify_post_receive:
true
)
expect
(
Time
).
to
receive
(
:now
).
and_return
(
enqueued_at
)
expect
(
Time
).
to
receive
(
:now
).
and_return
(
enqueued_at
)
end
end
...
@@ -172,6 +173,15 @@ describe GitlabPostReceive do
...
@@ -172,6 +173,15 @@ describe GitlabPostReceive do
end
end
end
end
context
'post_receive notification'
do
it
'calls the api to notify the execution of the hook'
do
expect_any_instance_of
(
GitlabNet
).
to
receive
(
:notify_post_receive
).
with
(
repo_path
)
gitlab_post_receive
.
exec
end
end
context
"when the redis command succeeds"
do
context
"when the redis command succeeds"
do
before
do
before
do
...
...
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