Commit b98d59ac authored by Alejandro Rodríguez's avatar Alejandro Rodríguez

Add gitaly notification on post-receive hook

parent f61bdfe3
...@@ -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
......
...@@ -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
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment