Skip to content
Snippets Groups Projects
Commit 28a22d8a authored by Andrew Ang's avatar Andrew Ang
Browse files

Allow Project#skip_refs to accept & match regex

* Added rspec tests for #skip_ref?
* Allow regex matching
* Added hints on Project form
parent 77c5ca24
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -155,7 +155,11 @@ ls -la
 
def skip_ref?(ref_name)
if skip_refs.present?
skip_refs.delete(" ").split(",").include?(ref_name)
skip_refs.delete(" ").split(",").each do |ref|
return true unless ref_name !~ Regexp.new(ref)
end
false
else
false
end
Loading
Loading
Loading
Loading
@@ -124,7 +124,9 @@
.form-group
= f.label :skip_refs, "Skip refs", class: 'control-label'
.col-sm-10
= f.text_field :skip_refs, class: 'form-control', placeholder: 'branch1, branch2'
= f.text_field :skip_refs, class: 'form-control', placeholder: 'branch1, branch2, feature/*'
.light
You can specify git references to skip CI builds. Accepts strings and regex values
 
.form-actions
= f.submit 'Save changes', class: 'btn btn-save'
Loading
Loading
Loading
Loading
@@ -132,4 +132,21 @@ describe Project do
it { should include('gitlab-ci-token') }
it { should include(project.gitlab_url[7..-1]) }
end
describe "#skip_ref?" do
let(:project) { FactoryGirl.create(:project, skip_refs: "master, develop, feature/.*, hotfix/*") }
it 'returns true when item is not in list' do
expect(project.skip_ref?('someotherstring')).to eq false
end
it 'accepts string values' do
expect(project.skip_ref?('master')).to eq true
end
it 'accepts regex values' do
expect(project.skip_ref?('feature/some_feature')).to eq true
expect(project.skip_ref?('feature/ssh_fix')).to eq true
end
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