summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSato Hiroyuki <sathiroyuki@gmail.com>2013-03-19 10:00:29 +0900
committerSato Hiroyuki <sathiroyuki@gmail.com>2013-03-19 10:00:29 +0900
commit46fa92187d6c076619e9cd58877e03c6d15a1f03 (patch)
treefb9ae2a1edfcaa28146ac0380da2750d52b689c6 /app
parent7587a3b2fc0e0a3e39e969172f00391c2053e8b9 (diff)
downloadgitlab-ce-46fa92187d6c076619e9cd58877e03c6d15a1f03.tar.gz
Refactor: removing duplicate code.
Diffstat (limited to 'app')
-rw-r--r--app/models/network/graph.rb24
1 files changed, 14 insertions, 10 deletions
diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb
index 074ec371fd2..16512b90f77 100644
--- a/app/models/network/graph.rb
+++ b/app/models/network/graph.rb
@@ -25,15 +25,7 @@ module Network
def collect_commits
refs_cache = build_refs_cache
- Grit::Commit.find_all(
- @repo,
- nil,
- {
- date_order: true,
- max_count: self.class.max_count,
- skip: count_to_display_commit_in_center
- }
- )
+ find_commits(count_to_display_commit_in_center)
.map do |commit|
# Decorate with app/model/network/commit.rb
Network::Commit.new(commit, refs_cache[commit.id])
@@ -74,7 +66,7 @@ module Network
# Skip count that the target commit is displayed 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
end
@@ -86,6 +78,18 @@ module Network
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
@commits.sort do |a,b|
if include_ref?(a)