Commit 46fa9218 authored by Sato Hiroyuki's avatar Sato Hiroyuki

Refactor: removing duplicate code.

parent 7587a3b2
...@@ -25,15 +25,7 @@ module Network ...@@ -25,15 +25,7 @@ module Network
def collect_commits def collect_commits
refs_cache = build_refs_cache refs_cache = build_refs_cache
Grit::Commit.find_all( find_commits(count_to_display_commit_in_center)
@repo,
nil,
{
date_order: true,
max_count: self.class.max_count,
skip: count_to_display_commit_in_center
}
)
.map do |commit| .map do |commit|
# Decorate with app/model/network/commit.rb # Decorate with app/model/network/commit.rb
Network::Commit.new(commit, refs_cache[commit.id]) Network::Commit.new(commit, refs_cache[commit.id])
...@@ -74,7 +66,7 @@ module Network ...@@ -74,7 +66,7 @@ module Network
# Skip count that the target commit is displayed in center. # Skip count that the target commit is displayed in center.
def count_to_display_commit_in_center def count_to_display_commit_in_center
commit_index = Grit::Commit.find_all(@repo, nil, {date_order: true}).index do |c| commit_index = find_commits.index do |c|
c.id == @commit.id c.id == @commit.id
end end
...@@ -86,6 +78,18 @@ module Network ...@@ -86,6 +78,18 @@ module Network
end end
end end
def find_commits(skip = 0)
Grit::Commit.find_all(
@repo,
nil,
{
date_order: true,
max_count: self.class.max_count,
skip: skip
}
)
end
def commits_sort_by_ref def commits_sort_by_ref
@commits.sort do |a,b| @commits.sort do |a,b|
if include_ref?(a) if include_ref?(a)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment