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 181  
182 182 def add_refs(commit, ref_cache)
183 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 188 end
186 189 commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id
187 190 commit.refs ||= []
... ...
lib/graph_commit.rb
... ... @@ -25,7 +25,7 @@ class GraphCommit
25 25  
26 26 commits.reverse.each_with_index do |c,i|
27 27 c.time = i
28   - days[i]=c.committed_date
  28 + days[i] = c.committed_date
29 29 map[c.id] = c
30 30 heads += c.refs unless c.refs.nil?
31 31 end
... ... @@ -63,7 +63,7 @@ class GraphCommit
63 63 m1 = mark - 1
64 64 marks = commit.parents.collect do |p|
65 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 67 else
68 68 m1 + 1
69 69 end
... ... @@ -72,11 +72,4 @@ class GraphCommit
72 72 marks.compact.max
73 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 75 end
... ...