Skip to content
Snippets Groups Projects
Commit 113a50f1 authored by Jonathon Reinhart's avatar Jonathon Reinhart
Browse files

Add lib/push_options

This module is responsible for converting the GIT_PUSH_OPTION_*
environment variables into an array.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/18667
parent 2b575a8d
No related branches found
No related tags found
No related merge requests found
# Gets an array of Git push options from the environment
def get_push_options
result = []
count = ENV['GIT_PUSH_OPTION_COUNT'].to_i
if count
count.times do |i|
result.push(ENV["GIT_PUSH_OPTION_#{i}"])
end
end
return result
end
require_relative 'spec_helper'
require_relative '../lib/push_options.rb'
describe :get_push_options do
context "when GIT_PUSH_OPTION_COUNT is not set" do
get_push_options.should == []
end
context "when one option is given" do
ENV['GIT_PUSH_OPTION_COUNT'] = '1'
ENV['GIT_PUSH_OPTION_0'] = 'aaa'
get_push_options.should == ['aaa']
end
context "when multiple options are given" do
ENV['GIT_PUSH_OPTION_COUNT'] = '3'
ENV['GIT_PUSH_OPTION_0'] = 'aaa'
ENV['GIT_PUSH_OPTION_1'] = 'bbb'
ENV['GIT_PUSH_OPTION_2'] = 'ccc'
get_push_options.should == ['aaa', 'bbb', 'ccc']
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment