Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b7e5f455
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b7e5f455
编写于
3月 07, 2013
作者:
S
Sato Hiroyuki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor: Removing the duplicated code.
上级
79cd1ca3
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
40 addition
and
48 deletion
+40
-48
app/models/network/commit.rb
app/models/network/commit.rb
+9
-0
app/models/network/graph.rb
app/models/network/graph.rb
+30
-47
app/views/graph/show.json.erb
app/views/graph/show.json.erb
+1
-1
未找到文件。
app/models/network/commit.rb
浏览文件 @
b7e5f455
...
...
@@ -26,5 +26,14 @@ module Network
0
end
end
def
parents
(
map
)
@commit
.
parents
.
map
do
|
p
|
if
map
.
include?
(
p
.
id
)
map
[
p
.
id
]
end
end
.
compact
end
end
end
app/models/network/graph.rb
浏览文件 @
b7e5f455
...
...
@@ -2,7 +2,7 @@ require "grit"
module
Network
class
Graph
attr_reader
:days
,
:commits
attr_reader
:days
,
:commits
,
:map
def
self
.
max_count
@max_count
||=
650
...
...
@@ -61,10 +61,8 @@ module Network
end
commits_sort_by_ref
.
each
do
|
commit
|
if
@map
.
include?
commit
.
id
then
place_chain
(
commit
)
end
end
# find parent spaces for not overlap lines
@commits
.
each
do
|
c
|
...
...
@@ -115,10 +113,7 @@ module Network
def
find_free_parent_spaces
(
commit
)
spaces
=
[]
commit
.
parents
.
each
do
|
p
|
if
@map
.
include?
(
p
.
id
)
then
parent
=
@map
[
p
.
id
]
commit
.
parents
(
@map
).
each
do
|
parent
|
range
=
if
commit
.
time
<
parent
.
time
then
commit
.
time
..
parent
.
time
else
...
...
@@ -134,7 +129,6 @@ module Network
mark_reserved
(
range
,
space
)
spaces
<<
space
end
end
spaces
end
...
...
@@ -175,27 +169,20 @@ module Network
leaves
.
each
do
|
l
|
l
.
spaces
<<
space
# Also add space to parent
l
.
parents
.
each
do
|
p
|
if
@map
.
include?
(
p
.
id
)
parent
=
@map
[
p
.
id
]
l
.
parents
(
@map
).
each
do
|
parent
|
if
parent
.
space
>
0
parent
.
spaces
<<
space
end
end
end
end
# and mark it as reserved
min_time
=
leaves
.
last
.
time
parents
=
leaves
.
last
.
parents
.
collect
parents
.
each
do
|
p
|
if
@map
.
include?
p
.
id
parent
=
@map
[
p
.
id
]
leaves
.
last
.
parents
(
@map
).
each
do
|
parent
|
if
parent
.
time
<
min_time
min_time
=
parent
.
time
end
end
end
if
parent_time
.
nil?
max_time
=
leaves
.
first
.
time
...
...
@@ -206,7 +193,7 @@ module Network
# Visit branching chains
leaves
.
each
do
|
l
|
parents
=
l
.
parents
.
collect
.
select
{
|
p
|
@map
.
include?
p
.
id
and
@map
[
p
.
id
]
.
space
.
zero?
}
parents
=
l
.
parents
(
@map
).
select
{
|
p
|
p
.
space
.
zero?
}
for
p
in
parents
place_chain
(
p
,
l
.
time
)
end
...
...
@@ -215,13 +202,10 @@ module Network
def
get_space_base
(
leaves
)
space_base
=
1
if
leaves
.
last
.
parents
.
size
>
0
first_parent
=
leaves
.
last
.
parents
.
first
if
@map
.
include?
(
first_parent
.
id
)
first_p
=
@map
[
first_parent
.
id
]
if
first_p
.
space
>
0
space_base
=
first_p
.
space
end
parents
=
leaves
.
last
.
parents
(
@map
)
if
parents
.
size
>
0
if
parents
.
first
.
space
>
0
space_base
=
parents
.
first
.
space
end
end
space_base
...
...
@@ -266,10 +250,9 @@ module Network
leaves
.
push
(
commit
)
if
commit
.
space
.
zero?
while
true
return
leaves
if
commit
.
parents
.
count
.
zero?
return
leaves
unless
@map
.
include?
commit
.
parents
.
first
.
id
return
leaves
if
commit
.
parents
(
@map
).
count
.
zero?
commit
=
@map
[
commit
.
parents
.
first
.
id
]
commit
=
commit
.
parents
(
@map
).
first
return
leaves
unless
commit
.
space
.
zero?
...
...
app/views/graph/show.json.erb
浏览文件 @
b7e5f455
...
...
@@ -5,7 +5,7 @@
days:
@graph
.
days
.
compact
.
map
{
|
d
|
[
d
.
day
,
d
.
strftime
(
"%b"
)]
},
commits:
@graph
.
commits
.
map
do
|
c
|
{
parents:
parents_zip_spaces
(
c
.
parents
,
c
.
parent_spaces
),
parents:
parents_zip_spaces
(
c
.
parents
(
@graph
.
map
)
,
c
.
parent_spaces
),
author:
{
name:
c
.
author
.
name
,
email:
c
.
author
.
email
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录