Commit 70687cd5812a53ce574589f4f7ce6a6d683c2f07

Authored by Sato Hiroyuki
Committed by GitLab
1 parent 65737bd5

Improve network graph

lib/gitlab/graph/json_builder.rb
@@ -16,6 +16,7 @@ module Gitlab @@ -16,6 +16,7 @@ module Gitlab
16 16
17 @commits = collect_commits 17 @commits = collect_commits
18 @days = index_commits 18 @days = index_commits
  19 + @space = 0
19 end 20 end
20 21
21 def to_json(*args) 22 def to_json(*args)
@@ -97,8 +98,8 @@ module Gitlab @@ -97,8 +98,8 @@ module Gitlab
97 if leaves.empty? 98 if leaves.empty?
98 return 99 return
99 end 100 end
100 - space = find_free_space(leaves, map)  
101 - leaves.each{|l| l.space = space} 101 + @space = find_free_space(leaves, map)
  102 + leaves.each{|l| l.space = @space}
102 # and mark it as reserved 103 # and mark it as reserved
103 min_time = leaves.last.time 104 min_time = leaves.last.time
104 parents = leaves.last.parents.collect 105 parents = leaves.last.parents.collect
@@ -115,7 +116,7 @@ module Gitlab @@ -115,7 +116,7 @@ module Gitlab
115 else 116 else
116 max_time = parent_time - 1 117 max_time = parent_time - 1
117 end 118 end
118 - mark_reserved(min_time..max_time, space) 119 + mark_reserved(min_time..max_time, @space)
119 120
120 # Visit branching chains 121 # Visit branching chains
121 leaves.each do |l| 122 leaves.each do |l|
@@ -139,9 +140,10 @@ module Gitlab @@ -139,9 +140,10 @@ module Gitlab
139 reserved += @_reserved[day] 140 reserved += @_reserved[day]
140 end 141 end
141 space = base_space(leaves, map) 142 space = base_space(leaves, map)
142 - while reserved.include? space do 143 + while (reserved.include? space) || (space == @space) do
143 space += 1 144 space += 1
144 end 145 end
  146 +
145 space 147 space
146 end 148 end
147 149
vendor/assets/javascripts/branch-graph.js
@@ -121,7 +121,7 @@ @@ -121,7 +121,7 @@
121 if (c.space == this.commits[i].space) { 121 if (c.space == this.commits[i].space) {
122 r.path([ 122 r.path([
123 "M", x, y, 123 "M", x, y,
124 - "L", x - 20 * (c.time + 1), y 124 + "L", cx, cy
125 ]).attr({ 125 ]).attr({
126 stroke: this.colors[c.space], 126 stroke: this.colors[c.space],
127 "stroke-width": 2 127 "stroke-width": 2
@@ -351,4 +351,4 @@ function textWrap(t, width) { @@ -351,4 +351,4 @@ function textWrap(t, width) {
351 t.attr({ 351 t.attr({
352 "y": b.y + h 352 "y": b.y + h
353 }); 353 });
354 -}  
355 \ No newline at end of file 354 \ No newline at end of file
  355 +}