From: Valery Sizov Date: Sun, 13 Nov 2011 13:31:18 +0000 (+0200) Subject: Graph: small refactoring X-Git-Tag: v1.2.0pre~41 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=dc844f013848ee1fa7721173bda3f3fc0ed0b8ba;p=wvm%2Fgitlab.git Graph: small refactoring --- diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0564a82b0..7f662a437 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -181,7 +181,10 @@ class ProjectsController < ApplicationController def add_refs(commit, ref_cache) if ref_cache.empty? - @repo.refs.each {|ref| ref_cache[ref.commit.id] ||= [];ref_cache[ref.commit.id] << ref} + @repo.refs.each do |ref| + ref_cache[ref.commit.id] ||= [] + ref_cache[ref.commit.id] << ref + end end commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id commit.refs ||= [] diff --git a/lib/graph_commit.rb b/lib/graph_commit.rb index ee765cb4e..477f4f422 100644 --- a/lib/graph_commit.rb +++ b/lib/graph_commit.rb @@ -25,7 +25,7 @@ class GraphCommit commits.reverse.each_with_index do |c,i| c.time = i - days[i]=c.committed_date + days[i] = c.committed_date map[c.id] = c heads += c.refs unless c.refs.nil? end @@ -63,7 +63,7 @@ class GraphCommit m1 = mark - 1 marks = commit.parents.collect do |p| if map.include? p.id and map[p.id].space == 0 then - mark_chain(m1+=1, map[p.id],map) + mark_chain(m1 += 1, map[p.id],map) else m1 + 1 end @@ -72,11 +72,4 @@ class GraphCommit marks.compact.max end - def self.add_refs(commit, ref_cache) - if ref_cache.empty? - @repo.refs.each {|ref| ref_cache[ref.commit.id] ||= [];ref_cache[ref.commit.id] << ref} - end - commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id - commit.refs ||= [] - end end