Commit dc844f013848ee1fa7721173bda3f3fc0ed0b8ba

Authored by Valery Sizov
1 parent c8968260

Graph: small refactoring

app/controllers/projects_controller.rb
@@ -181,7 +181,10 @@ class ProjectsController < ApplicationController @@ -181,7 +181,10 @@ class ProjectsController < ApplicationController
181 181
182 def add_refs(commit, ref_cache) 182 def add_refs(commit, ref_cache)
183 if ref_cache.empty? 183 if ref_cache.empty?
184 - @repo.refs.each {|ref| ref_cache[ref.commit.id] ||= [];ref_cache[ref.commit.id] << ref} 184 + @repo.refs.each do |ref|
  185 + ref_cache[ref.commit.id] ||= []
  186 + ref_cache[ref.commit.id] << ref
  187 + end
185 end 188 end
186 commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id 189 commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id
187 commit.refs ||= [] 190 commit.refs ||= []
lib/graph_commit.rb
@@ -25,7 +25,7 @@ class GraphCommit @@ -25,7 +25,7 @@ class GraphCommit
25 25
26 commits.reverse.each_with_index do |c,i| 26 commits.reverse.each_with_index do |c,i|
27 c.time = i 27 c.time = i
28 - days[i]=c.committed_date 28 + days[i] = c.committed_date
29 map[c.id] = c 29 map[c.id] = c
30 heads += c.refs unless c.refs.nil? 30 heads += c.refs unless c.refs.nil?
31 end 31 end
@@ -63,7 +63,7 @@ class GraphCommit @@ -63,7 +63,7 @@ class GraphCommit
63 m1 = mark - 1 63 m1 = mark - 1
64 marks = commit.parents.collect do |p| 64 marks = commit.parents.collect do |p|
65 if map.include? p.id and map[p.id].space == 0 then 65 if map.include? p.id and map[p.id].space == 0 then
66 - mark_chain(m1+=1, map[p.id],map) 66 + mark_chain(m1 += 1, map[p.id],map)
67 else 67 else
68 m1 + 1 68 m1 + 1
69 end 69 end
@@ -72,11 +72,4 @@ class GraphCommit @@ -72,11 +72,4 @@ class GraphCommit
72 marks.compact.max 72 marks.compact.max
73 end 73 end
74 74
75 - def self.add_refs(commit, ref_cache)  
76 - if ref_cache.empty?  
77 - @repo.refs.each {|ref| ref_cache[ref.commit.id] ||= [];ref_cache[ref.commit.id] << ref}  
78 - end  
79 - commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id  
80 - commit.refs ||= []  
81 - end  
82 end 75 end