Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
452adb7b
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,发现更多精彩内容 >>
提交
452adb7b
编写于
2月 12, 2013
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'hiroponz-easy-to-find-commit-on-network-graph'
上级
d6513b51
622dae76
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
99 addition
and
34 deletion
+99
-34
app/assets/stylesheets/gitlab_bootstrap/common.scss
app/assets/stylesheets/gitlab_bootstrap/common.scss
+1
-0
app/controllers/graph_controller.rb
app/controllers/graph_controller.rb
+11
-1
app/views/graph/_head.html.haml
app/views/graph/_head.html.haml
+16
-0
app/views/graph/show.html.haml
app/views/graph/show.html.haml
+4
-6
lib/extracts_path.rb
lib/extracts_path.rb
+4
-1
lib/gitlab/graph/json_builder.rb
lib/gitlab/graph/json_builder.rb
+48
-20
vendor/assets/javascripts/branch-graph.js
vendor/assets/javascripts/branch-graph.js
+15
-6
未找到文件。
app/assets/stylesheets/gitlab_bootstrap/common.scss
浏览文件 @
452adb7b
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
.hint
{
font-style
:
italic
;
color
:
#999
;
}
.hint
{
font-style
:
italic
;
color
:
#999
;
}
.light
{
color
:
#888
}
.light
{
color
:
#888
}
.tiny
{
font-weight
:
normal
}
.tiny
{
font-weight
:
normal
}
.vtop
{
vertical-align
:
top
;
}
/** ALERT MESSAGES **/
/** ALERT MESSAGES **/
...
...
app/controllers/graph_controller.rb
浏览文件 @
452adb7b
...
@@ -7,10 +7,20 @@ class GraphController < ProjectResourceController
...
@@ -7,10 +7,20 @@ class GraphController < ProjectResourceController
before_filter
:require_non_empty_project
before_filter
:require_non_empty_project
def
show
def
show
if
params
.
has_key?
(
:q
)
&&
params
[
:q
].
blank?
redirect_to
project_graph_path
(
@project
,
params
[
:id
])
return
end
if
params
.
has_key?
(
:q
)
@q
=
params
[
:q
]
@commit
=
@project
.
repository
.
commit
(
@q
)
||
@commit
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
do
format
.
json
do
graph
=
Gitlab
::
Graph
::
JsonBuilder
.
new
(
project
,
@ref
)
graph
=
Gitlab
::
Graph
::
JsonBuilder
.
new
(
project
,
@ref
,
@commit
)
render
:json
=>
graph
.
to_json
render
:json
=>
graph
.
to_json
end
end
end
end
...
...
app/views/graph/_head.html.haml
0 → 100644
浏览文件 @
452adb7b
%h3
.page_title
Project Network Graph
%hr
.clearfix
.pull-left
=
render
partial:
'shared/ref_switcher'
,
locals:
{
destination:
'graph'
,
path:
@path
}
.search.pull-right
=
form_tag
project_graph_path
(
@project
,
params
[
:id
]),
method: :get
do
|
f
|
.control-group
=
label_tag
:search
,
"Looking for commit:"
,
class:
'control-label light'
.controls
=
text_field_tag
:q
,
@q
,
placeholder:
"Input SHA"
,
class:
"search-input xlarge"
=
button_tag
type:
'submit'
,
class:
'btn vtop'
do
%i
.icon-search
app/views/graph/show.html.haml
浏览文件 @
452adb7b
%h3
.page_title
Project Network Graph
=
render
"head"
%br
=
render
partial:
'shared/ref_switcher'
,
locals:
{
destination:
'graph'
,
path:
@path
}
%br
.graph_holder
.graph_holder
%h4
%h4
%small
You can move around the graph by using the arrow keys.
%small
You can move around the graph by using the arrow keys.
...
@@ -12,8 +9,9 @@
...
@@ -12,8 +9,9 @@
var
branch_graph
;
var
branch_graph
;
$
(
function
(){
$
(
function
(){
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
format: :json
)
}
'
,
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
q:
@q
,
format: :json
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
ref
:
'
#{
@ref
}
'
ref
:
'
#{
@ref
}
'
,
commit_id
:
'
#{
@commit
.
id
}
'
});
});
});
});
lib/extracts_path.rb
浏览文件 @
452adb7b
...
@@ -117,7 +117,10 @@ module ExtractsPath
...
@@ -117,7 +117,10 @@ module ExtractsPath
@id
=
File
.
join
(
@ref
,
@path
)
@id
=
File
.
join
(
@ref
,
@path
)
@commit
=
CommitDecorator
.
decorate
(
@project
.
repository
.
commit
(
@ref
))
# It is used "@project.repository.commits(@ref, @path, 1, 0)",
# because "@project.repository.commit(@ref)" returns wrong commit when @ref is tag name.
commits
=
@project
.
repository
.
commits
(
@ref
,
@path
,
1
,
0
)
@commit
=
CommitDecorator
.
decorate
(
commits
.
first
)
@tree
=
Tree
.
new
(
@commit
.
tree
,
@ref
,
@path
)
@tree
=
Tree
.
new
(
@commit
.
tree
,
@ref
,
@path
)
@tree
=
TreeDecorator
.
new
(
@tree
)
@tree
=
TreeDecorator
.
new
(
@tree
)
...
...
lib/gitlab/graph/json_builder.rb
浏览文件 @
452adb7b
...
@@ -9,9 +9,10 @@ module Gitlab
...
@@ -9,9 +9,10 @@ module Gitlab
@max_count
||=
650
@max_count
||=
650
end
end
def
initialize
project
,
ref
def
initialize
project
,
ref
,
commit
@project
=
project
@project
=
project
@ref
=
ref
@ref
=
ref
@commit
=
commit
@repo
=
project
.
repo
@repo
=
project
.
repo
@ref_cache
=
{}
@ref_cache
=
{}
...
@@ -31,7 +32,8 @@ module Gitlab
...
@@ -31,7 +32,8 @@ module Gitlab
# Get commits from repository
# Get commits from repository
#
#
def
collect_commits
def
collect_commits
@commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
,
{
max_count:
self
.
class
.
max_count
}).
dup
@commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
,
{
topo_order:
true
,
max_count:
self
.
class
.
max_count
,
skip:
to_commit
}).
dup
# Decorate with app/models/commit.rb
# Decorate with app/models/commit.rb
@commits
.
map!
{
|
commit
|
::
Commit
.
new
(
commit
)
}
@commits
.
map!
{
|
commit
|
::
Commit
.
new
(
commit
)
}
...
@@ -49,41 +51,28 @@ module Gitlab
...
@@ -49,41 +51,28 @@ module Gitlab
# list of commits. As well as returns date list
# list of commits. As well as returns date list
# corelated with time set on commits.
# corelated with time set on commits.
#
#
# @param [Array<Graph::Commit>] comits to index
# @param [Array<Graph::Commit>] com
m
its to index
#
#
# @return [Array<TimeDate>] list of commit dates corelated with time on commits
# @return [Array<TimeDate>] list of commit dates corelated with time on commits
def
index_commits
def
index_commits
days
,
heads
,
times
=
[],
[],
[]
days
,
times
=
[],
[]
map
=
{}
map
=
{}
commits
.
reverse
.
each_with_index
do
|
c
,
i
|
commits
.
reverse
.
each_with_index
do
|
c
,
i
|
c
.
time
=
i
c
.
time
=
i
days
[
i
]
=
c
.
committed_date
days
[
i
]
=
c
.
committed_date
map
[
c
.
id
]
=
c
map
[
c
.
id
]
=
c
heads
+=
c
.
refs
unless
c
.
refs
.
nil?
times
[
i
]
=
c
times
[
i
]
=
c
end
end
heads
.
select!
{
|
h
|
h
.
is_a?
Grit
::
Head
or
h
.
is_a?
Grit
::
Remote
}
# sort heads so the master is top and current branches are closer
heads
.
sort!
do
|
a
,
b
|
if
a
.
name
==
@ref
-
1
elsif
b
.
name
==
@ref
1
else
b
.
commit
.
committed_date
<=>
a
.
commit
.
committed_date
end
end
@_reserved
=
{}
@_reserved
=
{}
days
.
each_index
do
|
i
|
days
.
each_index
do
|
i
|
@_reserved
[
i
]
=
[]
@_reserved
[
i
]
=
[]
end
end
heads
.
each
do
|
h
|
commits_sort_by_ref
.
each
do
|
commit
|
if
map
.
include?
h
.
commit
.
id
then
if
map
.
include?
commit
.
id
then
place_chain
(
map
[
h
.
commit
.
id
],
map
)
place_chain
(
map
[
commit
.
id
],
map
)
end
end
end
end
...
@@ -95,6 +84,45 @@ module Gitlab
...
@@ -95,6 +84,45 @@ module Gitlab
days
days
end
end
# Skip count that the target commit is displayed in center.
def
to_commit
commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
,
{
topo_order:
true
})
commit_index
=
commits
.
index
do
|
c
|
c
.
id
==
@commit
.
id
end
if
commit_index
&&
(
self
.
class
.
max_count
/
2
<
commit_index
)
then
# get max index that commit is displayed in the center.
commit_index
-
self
.
class
.
max_count
/
2
else
0
end
end
def
commits_sort_by_ref
commits
.
sort
do
|
a
,
b
|
if
include_ref?
(
a
)
-
1
elsif
include_ref?
(
b
)
1
else
b
.
committed_date
<=>
a
.
committed_date
end
end
end
def
include_ref?
(
commit
)
heads
=
commit
.
refs
.
select
do
|
ref
|
ref
.
is_a?
(
Grit
::
Head
)
or
ref
.
is_a?
(
Grit
::
Remote
)
or
ref
.
is_a?
(
Grit
::
Tag
)
end
heads
.
map!
do
|
head
|
head
.
name
end
heads
.
include?
(
@ref
)
end
def
find_free_parent_spaces
(
commit
,
map
,
times
)
def
find_free_parent_spaces
(
commit
,
map
,
times
)
spaces
=
[]
spaces
=
[]
...
...
vendor/assets/javascripts/branch-graph.js
浏览文件 @
452adb7b
...
@@ -161,14 +161,23 @@
...
@@ -161,14 +161,23 @@
if
(
this
.
commits
[
i
].
refs
)
{
if
(
this
.
commits
[
i
].
refs
)
{
this
.
appendLabel
(
x
,
y
,
this
.
commits
[
i
].
refs
);
this
.
appendLabel
(
x
,
y
,
this
.
commits
[
i
].
refs
);
// The main branch is displayed in the center.
re
=
new
RegExp
(
'
(^| )
'
+
this
.
options
.
ref
+
'
( |$)
'
);
if
(
this
.
commits
[
i
].
refs
.
match
(
re
))
{
scrollLeft
=
x
-
graphWidth
/
2
;
}
}
}
// mark commit and displayed in the center
if
(
this
.
commits
[
i
].
id
==
this
.
options
.
commit_id
)
{
r
.
path
([
'
M
'
,
x
,
y
-
5
,
'
L
'
,
x
+
4
,
y
-
15
,
'
L
'
,
x
-
4
,
y
-
15
,
'
Z
'
]).
attr
({
"
fill
"
:
"
#000
"
,
"
fill-opacity
"
:
.
7
,
"
stroke
"
:
"
none
"
});
scrollLeft
=
x
-
graphWidth
/
2
;
}
this
.
appendAnchor
(
top
,
this
.
commits
[
i
],
x
,
y
);
this
.
appendAnchor
(
top
,
this
.
commits
[
i
],
x
,
y
);
}
}
top
.
toFront
();
top
.
toFront
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录