Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroyuki Sato <sathiroyuki@gmail.com>2013-08-20 07:05:23 +0400
committerHiroyuki Sato <sathiroyuki@gmail.com>2013-08-20 07:05:23 +0400
commitfd0afcc996d687232c1181263b17793b2827d44e (patch)
tree06839797007893a37a1ecc16a311b8a8fa998999 /app/models/network
parent65cba5c6b91483f7f629c9bb2dcd98e2da92405c (diff)
Remove the dependancy of grit from class Network::Graph
Diffstat (limited to 'app/models/network')
-rw-r--r--app/models/network/commit.rb6
-rw-r--r--app/models/network/graph.rb34
2 files changed, 8 insertions, 32 deletions
diff --git a/app/models/network/commit.rb b/app/models/network/commit.rb
index 3cd0c015fa0..e31adcebbe7 100644
--- a/app/models/network/commit.rb
+++ b/app/models/network/commit.rb
@@ -4,15 +4,13 @@ module Network
class Commit
include ActionView::Helpers::TagHelper
- attr_reader :refs
attr_accessor :time, :spaces, :parent_spaces
- def initialize(raw_commit, refs)
- @commit = Gitlab::Git::Commit.new(raw_commit)
+ def initialize(raw_commit)
+ @commit = raw_commit
@time = -1
@spaces = []
@parent_spaces = []
- @refs = refs || []
end
def method_missing(m, *args, &block)
diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb
index 1d21e96369a..424819f3501 100644
--- a/app/models/network/graph.rb
+++ b/app/models/network/graph.rb
@@ -1,8 +1,6 @@
-require "grit"
-
module Network
class Graph
- attr_reader :days, :commits, :map, :notes
+ attr_reader :days, :commits, :map, :notes, :repo
def self.max_count
@max_count ||= 650
@@ -13,7 +11,7 @@ module Network
@ref = ref
@commit = commit
@filter_ref = filter_ref
- @repo = project.repo
+ @repo = project.repository
@commits = collect_commits
@days = index_commits
@@ -33,11 +31,9 @@ module Network
# Get commits from repository
#
def collect_commits
- refs_cache = build_refs_cache
-
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])
+ Network::Commit.new(commit)
end
end
@@ -103,14 +99,13 @@ module Network
def find_commits(skip = 0)
opts = {
- date_order: true,
max_count: self.class.max_count,
skip: skip
}
- ref = @ref if @filter_ref
+ opts[:ref] = @commit.id if @filter_ref
- Grit::Commit.find_all(@repo, ref, opts)
+ @repo.find_commits(opts)
end
def commits_sort_by_ref
@@ -126,15 +121,7 @@ module Network
end
def include_ref?(commit)
- heads = commit.refs.select do |ref|
- ref.is_a?(Grit::Head) or ref.is_a?(Grit::Remote) or ref.is_a?(Grit::Tag)
- end
-
- heads.map! do |head|
- head.name
- end
-
- heads.include?(@ref)
+ commit.ref_names(@repo).include?(@ref)
end
def find_free_parent_spaces(commit)
@@ -282,14 +269,5 @@ module Network
leaves.push(commit)
end
end
-
- def build_refs_cache
- refs_cache = {}
- @repo.refs.each do |ref|
- refs_cache[ref.commit.id] = [] unless refs_cache.include?(ref.commit.id)
- refs_cache[ref.commit.id] << ref
- end
- refs_cache
- end
end
end