From 8b34687a36c1ec4e558724513bcabdfa3b706854 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 8 Jun 2016 15:43:43 +0800 Subject: [PATCH] Merge conditions. Not worth an additional pointless method: Feedback from: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4093#note_12321267 --- app/models/ci/runner.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 9bd4d3ab0a5..bb1cffdcae6 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -99,9 +99,7 @@ module Ci end def can_pick?(build) - available_for?(build.project) && - run_untagged_or_has_tags?(build) && - accepting_tags?(build.tag_list) + available_for?(build.project) && accepting_tags?(build) end def only_for?(project) @@ -129,12 +127,8 @@ module Ci !locked? || projects.exists?(id: project.id) end - def run_untagged_or_has_tags?(build) - run_untagged? || build.has_tags? - end - - def accepting_tags?(target_tags) - (target_tags - tag_list).empty? + def accepting_tags?(build) + (run_untagged? || build.has_tags?) && (build.tag_list - tag_list).empty? end end end