Commit af705c3f authored by Jonathon Reinhart's avatar Jonathon Reinhart

Use 'push_options' everywhere instead of 'push_opts'

parent 30a06eca
...@@ -12,9 +12,9 @@ require_relative '../lib/gitlab_custom_hook' ...@@ -12,9 +12,9 @@ require_relative '../lib/gitlab_custom_hook'
require_relative '../lib/hooks_utils' require_relative '../lib/hooks_utils'
require_relative '../lib/gitlab_post_receive' require_relative '../lib/gitlab_post_receive'
push_opts = HooksUtils.get_push_options push_options = HooksUtils.get_push_options
if GitlabPostReceive.new(gl_repository, repo_path, key_id, refs, push_opts).exec && if GitlabPostReceive.new(gl_repository, repo_path, key_id, refs, push_options).exec &&
GitlabCustomHook.new(repo_path, key_id).post_receive(refs) GitlabCustomHook.new(repo_path, key_id).post_receive(refs)
exit 0 exit 0
else else
......
...@@ -119,12 +119,12 @@ class GitlabNet # rubocop:disable Metrics/ClassLength ...@@ -119,12 +119,12 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
false false
end end
def post_receive(gl_repository, identifier, changes, push_opts) def post_receive(gl_repository, identifier, changes, push_options)
params = { params = {
gl_repository: gl_repository, gl_repository: gl_repository,
identifier: identifier, identifier: identifier,
changes: changes, changes: changes,
:"push_opts[]" => push_opts, # ruby <2.2 syntax :"push_options[]" => push_options, # ruby <2.2 syntax
} }
resp = post("#{internal_api_endpoint}/post_receive", params) resp = post("#{internal_api_endpoint}/post_receive", params)
......
...@@ -8,19 +8,19 @@ require 'securerandom' ...@@ -8,19 +8,19 @@ require 'securerandom'
class GitlabPostReceive class GitlabPostReceive
attr_reader :config, :gl_repository, :repo_path, :changes, :jid attr_reader :config, :gl_repository, :repo_path, :changes, :jid
def initialize(gl_repository, repo_path, actor, changes, push_opts) def initialize(gl_repository, repo_path, actor, changes, push_options)
@config = GitlabConfig.new @config = GitlabConfig.new
@gl_repository = gl_repository @gl_repository = gl_repository
@repo_path = repo_path.strip @repo_path = repo_path.strip
@actor = actor @actor = actor
@changes = changes @changes = changes
@push_opts = push_opts @push_options = push_options
@jid = SecureRandom.hex(12) @jid = SecureRandom.hex(12)
end end
def exec def exec
response = GitlabMetrics.measure("post-receive") do response = GitlabMetrics.measure("post-receive") do
api.post_receive(gl_repository, @actor, changes, @push_opts) api.post_receive(gl_repository, @actor, changes, @push_options)
end end
return false unless response return false unless response
......
...@@ -174,9 +174,9 @@ describe GitlabNet, vcr: true do ...@@ -174,9 +174,9 @@ describe GitlabNet, vcr: true do
describe '#post_receive' do describe '#post_receive' do
let(:gl_repository) { "project-1" } let(:gl_repository) { "project-1" }
let(:changes) { "123456 789012 refs/heads/test\n654321 210987 refs/tags/tag" } let(:changes) { "123456 789012 refs/heads/test\n654321 210987 refs/tags/tag" }
let(:push_opts) { ["ci-skip", "something unexpected"] } let(:push_options) { ["ci-skip", "something unexpected"] }
let(:params) do let(:params) do
{ gl_repository: gl_repository, identifier: key, changes: changes, :"push_opts[]" => push_opts } { gl_repository: gl_repository, identifier: key, changes: changes, :"push_options[]" => push_options }
end end
let(:merge_request_urls) do let(:merge_request_urls) do
[{ [{
...@@ -186,7 +186,7 @@ describe GitlabNet, vcr: true do ...@@ -186,7 +186,7 @@ describe GitlabNet, vcr: true do
}] }]
end end
subject { gitlab_net.post_receive(gl_repository, key, changes, push_opts) } subject { gitlab_net.post_receive(gl_repository, key, changes, push_options) }
it 'sends the correct parameters' do it 'sends the correct parameters' do
expect_any_instance_of(Net::HTTP::Post).to receive(:set_form_data).with(hash_including(params)) expect_any_instance_of(Net::HTTP::Post).to receive(:set_form_data).with(hash_including(params))
......
...@@ -11,8 +11,8 @@ describe GitlabPostReceive do ...@@ -11,8 +11,8 @@ describe GitlabPostReceive do
let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) } let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) }
let(:repo_path) { File.join(repository_path, repo_name) + ".git" } let(:repo_path) { File.join(repository_path, repo_name) + ".git" }
let(:gl_repository) { "project-1" } let(:gl_repository) { "project-1" }
let(:push_opts) { [] } let(:push_options) { [] }
let(:gitlab_post_receive) { GitlabPostReceive.new(gl_repository, repo_path, actor, wrongly_encoded_changes, push_opts) } let(:gitlab_post_receive) { GitlabPostReceive.new(gl_repository, repo_path, actor, wrongly_encoded_changes, push_options) }
let(:broadcast_message) { "test " * 10 + "message " * 10 } let(:broadcast_message) { "test " * 10 + "message " * 10 }
let(:enqueued_at) { Time.new(2016, 6, 23, 6, 59) } let(:enqueued_at) { Time.new(2016, 6, 23, 6, 59) }
let(:new_merge_request_urls) do let(:new_merge_request_urls) 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