summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-01-13 00:10:55 -0800
committerStan Hu <stanhu@gmail.com>2018-01-13 00:50:23 -0800
commit69535c142303145c0c20b6dc6480e5a77ff3801d (patch)
tree6bc08790db1d7f1bb52241ff7f993d8d57a816e8
parenta478813e1e0c792733ef4a7639d8191bd20a0261 (diff)
downloadgitlab-shell-sh-remove-reference-counter.tar.gz
Remove remaining artifacts of reference countersh-remove-reference-counter
Closes gitlab-org/gitlab-qa#158
-rwxr-xr-xhooks/pre-receive14
-rw-r--r--lib/gitlab_post_receive.rb2
-rw-r--r--spec/gitlab_net_spec.rb7
-rw-r--r--spec/gitlab_post_receive_spec.rb6
-rw-r--r--spec/vcr_cassettes/post-receive.yml2
-rw-r--r--spec/vcr_cassettes/pre-receive.yml2
6 files changed, 6 insertions, 27 deletions
diff --git a/hooks/pre-receive b/hooks/pre-receive
index d113697..72e3d7d 100755
--- a/hooks/pre-receive
+++ b/hooks/pre-receive
@@ -9,24 +9,12 @@ protocol = ENV.delete('GL_PROTOCOL')
repo_path = Dir.pwd
gl_repository = ENV['GL_REPOSITORY']
-def increase_reference_counter(gl_repository, repo_path)
- result = GitlabNet.new.pre_receive(gl_repository)
-
- result['reference_counter_increased']
-end
-
require_relative '../lib/gitlab_custom_hook'
-require_relative '../lib/gitlab_reference_counter'
require_relative '../lib/gitlab_access'
require_relative '../lib/gitlab_net'
-# It's important that on pre-receive `increase_reference_counter` gets executed
-# last so that it only runs if everything else succeeded. On post-receive on the
-# other hand, we run GitlabPostReceive first because the push is already done
-# and we don't want to skip it if the custom hook fails.
if GitlabAccess.new(gl_repository, repo_path, key_id, refs, protocol).exec &&
- GitlabCustomHook.new(repo_path, key_id).pre_receive(refs) &&
- increase_reference_counter(gl_repository, repo_path)
+ GitlabCustomHook.new(repo_path, key_id).pre_receive(refs)
exit 0
else
exit 1
diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb
index 3f411a0..b43cc30 100644
--- a/lib/gitlab_post_receive.rb
+++ b/lib/gitlab_post_receive.rb
@@ -28,7 +28,7 @@ class GitlabPostReceive
print_merge_request_links(response['merge_request_urls']) if response['merge_request_urls']
puts response['redirected_message'] if response['redirected_message']
- response['reference_counter_decreased']
+ true
rescue GitlabNet::ApiUnreachableError
false
end
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index 8e06fa8..513f529 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -139,12 +139,6 @@ describe GitlabNet, vcr: true do
VCR.use_cassette("pre-receive") { subject }
end
- it 'calls /internal/pre-receive' do
- VCR.use_cassette("pre-receive") do
- expect(subject['reference_counter_increased']).to be(true)
- end
- end
-
it 'throws a NotFound error when pre-receive is not available' do
VCR.use_cassette("pre-receive-not-found") do
expect { subject }.to raise_error(GitlabNet::NotFound)
@@ -181,7 +175,6 @@ describe GitlabNet, vcr: true do
VCR.use_cassette("post-receive") do
expect(subject['merge_request_urls']).to eq(merge_request_urls)
expect(subject['broadcast_message']).to eq('Message')
- expect(subject['reference_counter_decreased']).to eq(true)
end
end
diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb
index 1b43db0..d39abb4 100644
--- a/spec/gitlab_post_receive_spec.rb
+++ b/spec/gitlab_post_receive_spec.rb
@@ -46,7 +46,6 @@ describe GitlabPostReceive do
context 'merge request urls and broadcast messages' do
let(:response) do
{
- 'reference_counter_decreased' => true,
'merge_request_urls' => new_merge_request_urls,
'broadcast_message' => broadcast_message
}
@@ -72,10 +71,9 @@ describe GitlabPostReceive do
MSG
end
let(:response) do
- {
- 'reference_counter_decreased' => true,
+ {
'redirected_message' => message
- }
+ }
end
it 'prints redirected message' do
diff --git a/spec/vcr_cassettes/post-receive.yml b/spec/vcr_cassettes/post-receive.yml
index c29f865..80d9d72 100644
--- a/spec/vcr_cassettes/post-receive.yml
+++ b/spec/vcr_cassettes/post-receive.yml
@@ -40,7 +40,7 @@ http_interactions:
- '0.687283'
body:
encoding: UTF-8
- string: '{"merge_request_urls":[{"branch_name":"test","url":"http://localhost:3000/gitlab-org/gitlab-test/merge_requests/7","new_merge_request":false}],"broadcast_message":"Message","reference_counter_decreased":true}'
+ string: '{"merge_request_urls":[{"branch_name":"test","url":"http://localhost:3000/gitlab-org/gitlab-test/merge_requests/7","new_merge_request":false}],"broadcast_message":"Message"}'
http_version:
recorded_at: Wed, 30 Aug 2017 22:08:28 GMT
recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/pre-receive.yml b/spec/vcr_cassettes/pre-receive.yml
index 6072d0c..41c4625 100644
--- a/spec/vcr_cassettes/pre-receive.yml
+++ b/spec/vcr_cassettes/pre-receive.yml
@@ -40,7 +40,7 @@ http_interactions:
- '0.612997'
body:
encoding: UTF-8
- string: '{"reference_counter_increased":true}'
+ string: '{}'
http_version:
recorded_at: Thu, 31 Aug 2017 20:17:41 GMT
recorded_with: VCR 2.4.0