From 5d14d52507352a4a0cb614f948dabbd85cc68298 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Mon, 29 Jun 2015 14:52:09 +0300 Subject: fix list of branches in only section --- CHANGELOG | 1 + lib/gitlab_ci_yaml_processor.rb | 4 ++-- spec/lib/gitlab_ci_yaml_processor_spec.rb | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4711964..2edeb8c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ v7.12.1 - Improved Lint stability - Add warning when .gitlab-ci.yml not found - Add one more validation rule for .gitlab-ci.yml + - Fix list of branches in only section v7.12.0 - Endless scroll on the dashboard diff --git a/lib/gitlab_ci_yaml_processor.rb b/lib/gitlab_ci_yaml_processor.rb index a6806d3..18ce1ad 100644 --- a/lib/gitlab_ci_yaml_processor.rb +++ b/lib/gitlab_ci_yaml_processor.rb @@ -65,8 +65,8 @@ class GitlabCiYamlProcessor return true if tag && only_params.include?("tags") return true if !tag && only_params.include?("branches") - only_params.each do |pattern| - return match_ref?(pattern, ref) + only_params.find do |pattern| + match_ref?(pattern, ref) end else return false if tag && except_params.include?("tags") diff --git a/spec/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/gitlab_ci_yaml_processor_spec.rb index 070e0c0..155fcf1 100644 --- a/spec/lib/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb @@ -117,6 +117,17 @@ describe GitlabCiYamlProcessor do config_processor.deploy_builds_for_ref("master").size.should == 1 end + + it "returns builds if only has a list of branches including specified" do + config = YAML.dump({ + before_script: ["pwd"], + rspec: {script: "rspec", type: "deploy", only: ["master", "deploy"]} + }) + + config_processor = GitlabCiYamlProcessor.new(config) + + config_processor.deploy_builds_for_ref("deploy").size.should == 1 + end end describe "Error handling" do -- cgit v1.2.1