Skip to content

Commit 094602f

Browse files
committed
Extract method
1 parent 0d3333d commit 094602f

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

app/services/github_hook/updater.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,7 @@ def find_project
7979
# Returns the Redmine Repository object we are trying to update
8080
def find_repositories
8181
project = find_project
82-
repositories = project.repositories.select do |repo|
83-
repo.is_a?(Repository::Git)
84-
end
85-
86-
if repositories.nil? || repositories.length == 0
87-
fail(
88-
TypeError,
89-
"Project '#{project}' ('#{project.identifier}') has no repository"
90-
)
91-
end
82+
repositories = git_repositories(project)
9283

9384
# if a specific repository id is passed in url parameter "repository_id",
9485
# then try to find it in the list of current project repositories and use
@@ -136,6 +127,19 @@ def git_command(command)
136127
GIT_BIN + " #{command}"
137128
end
138129

130+
def git_repositories(project)
131+
repositories = project.repositories.select do |repo|
132+
repo.is_a?(Repository::Git)
133+
end
134+
if repositories.empty?
135+
fail(
136+
TypeError,
137+
"Project '#{project}' ('#{project.identifier}') has no repository"
138+
)
139+
end
140+
repositories || []
141+
end
142+
139143
def logger
140144
@logger || NullLogger.new
141145
end

0 commit comments

Comments
 (0)