Skip to content

Commit

Permalink
cleaning up get projects matching code
Browse files Browse the repository at this point in the history
  • Loading branch information
elvanja committed Dec 8, 2014
1 parent 869c4f5 commit a56124c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions models/services/get_jenkins_projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ module GitlabWebHook
class GetJenkinsProjects
include Settings

def matching(details, exactly = false)
all.select do |project|
project.matches?(details.repository_uri, details.branch, details.full_branch_reference, exactly)
end.tap { |projects| log_matched(projects) }
def matching(details)
matching_projects(details, false)
end

def exactly_matching(details)
matching(details, true)
matching_projects(details, true)
end

def named(name)
Expand All @@ -48,6 +46,12 @@ def master(details)

private

def matching_projects(details, exactly = false)
all.select do |project|
project.matches?(details.repository_uri, details.branch, details.full_branch_reference, exactly)
end.tap { |projects| log_matched(projects) }
end

def all
old_authentication_level = elevate_priviledges
projects = Java.jenkins.model.Jenkins.instance.getAllItems(AbstractProject.java_class).map do |jenkins_project|
Expand Down

0 comments on commit a56124c

Please sign in to comment.