Commit 56000aea227c2805759db42f536d31ba3c533aff
Exists in
master
and in
4 other branches
Merge pull request #2855 from hiroponz/fix-bug-of-network-graph
Fix bug of network graph(#2847) and trivial code clean up.
Showing
2 changed files
with
16 additions
and
9 deletions
Show diff stats
lib/gitlab/graph/json_builder.rb
... | ... | @@ -109,9 +109,9 @@ module Gitlab |
109 | 109 | end |
110 | 110 | |
111 | 111 | space = if commit.space >= parent.space then |
112 | - find_free_parent_space(range, map, parent.space, 1, commit.space, times) | |
112 | + find_free_parent_space(range, parent.space, 1, commit.space, times) | |
113 | 113 | else |
114 | - find_free_parent_space(range, map, parent.space, -1, parent.space, times) | |
114 | + find_free_parent_space(range, parent.space, -1, parent.space, times) | |
115 | 115 | end |
116 | 116 | |
117 | 117 | mark_reserved(range, space) |
... | ... | @@ -122,9 +122,9 @@ module Gitlab |
122 | 122 | spaces |
123 | 123 | end |
124 | 124 | |
125 | - def find_free_parent_space(range, map, space_base, space_step, space_default, times) | |
125 | + def find_free_parent_space(range, space_base, space_step, space_default, times) | |
126 | 126 | if is_overlap?(range, times, space_default) then |
127 | - find_free_space(range, map, space_base, space_step) | |
127 | + find_free_space(range, space_base, space_step) | |
128 | 128 | else |
129 | 129 | space_default |
130 | 130 | end |
... | ... | @@ -152,11 +152,9 @@ module Gitlab |
152 | 152 | if leaves.empty? |
153 | 153 | return |
154 | 154 | end |
155 | - time_range = leaves.last.time..leaves.first.time | |
156 | - space = find_free_space(time_range, map, 1, 2) | |
157 | - leaves.each{|l| l.space = space} | |
158 | 155 | # and mark it as reserved |
159 | 156 | min_time = leaves.last.time |
157 | + max_space = 1 | |
160 | 158 | parents = leaves.last.parents.collect |
161 | 159 | parents.each do |p| |
162 | 160 | if map.include? p.id |
... | ... | @@ -164,6 +162,9 @@ module Gitlab |
164 | 162 | if parent.time < min_time |
165 | 163 | min_time = parent.time |
166 | 164 | end |
165 | + if max_space < parent.space then | |
166 | + max_space = parent.space | |
167 | + end | |
167 | 168 | end |
168 | 169 | end |
169 | 170 | if parent_time.nil? |
... | ... | @@ -171,6 +172,11 @@ module Gitlab |
171 | 172 | else |
172 | 173 | max_time = parent_time - 1 |
173 | 174 | end |
175 | + | |
176 | + time_range = leaves.last.time..leaves.first.time | |
177 | + space = find_free_space(time_range, max_space, 2) | |
178 | + leaves.each{|l| l.space = space} | |
179 | + | |
174 | 180 | mark_reserved(min_time..max_time, space) |
175 | 181 | |
176 | 182 | # Visit branching chains |
... | ... | @@ -188,11 +194,12 @@ module Gitlab |
188 | 194 | end |
189 | 195 | end |
190 | 196 | |
191 | - def find_free_space(time_range, map, space_base, space_step) | |
197 | + def find_free_space(time_range, space_base, space_step) | |
192 | 198 | reserved = [] |
193 | 199 | for day in time_range |
194 | 200 | reserved += @_reserved[day] |
195 | 201 | end |
202 | + reserved.uniq! | |
196 | 203 | |
197 | 204 | space = space_base |
198 | 205 | while reserved.include?(space) do | ... | ... |
vendor/assets/javascripts/branch-graph.js
... | ... | @@ -122,7 +122,7 @@ |
122 | 122 | var cx = offsetX + 20 * c.time |
123 | 123 | , cy = offsetY + 10 * c.space |
124 | 124 | , psy = offsetY + 10 * ps; |
125 | - if (c.space == this.commits[i].space) { | |
125 | + if (c.space == this.commits[i].space && c.space == ps) { | |
126 | 126 | r.path([ |
127 | 127 | "M", x, y, |
128 | 128 | "L", cx, cy | ... | ... |