Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9ea27db1
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,发现更多精彩内容 >>
提交
9ea27db1
编写于
5月 13, 2013
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3591 from hiroponz/show-only-selected-branch
Show only selected branch
上级
58d6176b
1738055d
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
87 addition
and
52 deletion
+87
-52
app/controllers/graph_controller.rb
app/controllers/graph_controller.rb
+3
-9
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+5
-30
app/controllers/tree_controller.rb
app/controllers/tree_controller.rb
+0
-3
app/models/network/graph.rb
app/models/network/graph.rb
+5
-2
app/views/graph/_head.html.haml
app/views/graph/_head.html.haml
+13
-3
app/views/graph/show.html.haml
app/views/graph/show.html.haml
+4
-2
app/views/shared/_ref_switcher.html.haml
app/views/shared/_ref_switcher.html.haml
+2
-0
features/project/network.feature
features/project/network.feature
+9
-0
features/steps/project/project_network_graph.rb
features/steps/project/project_network_graph.rb
+26
-0
lib/extracts_path.rb
lib/extracts_path.rb
+20
-3
未找到文件。
app/controllers/graph_controller.rb
浏览文件 @
9ea27db1
...
...
@@ -8,21 +8,15 @@ class GraphController < ProjectResourceController
before_filter
:require_non_empty_project
def
show
if
params
.
has_key?
(
:q
)
if
params
[
:q
].
blank?
redirect_to
project_graph_path
(
@project
,
params
[
:id
])
return
end
@q
=
params
[
:q
]
@commit
=
@project
.
repository
.
commit
(
@q
)
||
@commit
if
@options
[
:q
]
@commit
=
@project
.
repository
.
commit
(
@options
[
:q
])
||
@commit
end
respond_to
do
|
format
|
format
.
html
format
.
json
do
@graph
=
Network
::
Graph
.
new
(
project
,
@ref
,
@commit
)
@graph
=
Network
::
Graph
.
new
(
project
,
@ref
,
@commit
,
@options
[
:filter_ref
]
)
end
end
end
...
...
app/controllers/refs_controller.rb
浏览文件 @
9ea27db1
class
RefsController
<
ProjectResourceController
include
ExtractsPath
# Authorize
before_filter
:authorize_read_project!
before_filter
:authorize_code_access!
before_filter
:require_non_empty_project
before_filter
:ref
before_filter
:define_tree_vars
,
only:
[
:blob
,
:logs_tree
]
def
switch
respond_to
do
|
format
|
format
.
html
do
new_path
=
if
params
[
:destination
]
==
"tree"
project_tree_path
(
@project
,
(
@
ref
+
"/"
+
params
[
:path
]
))
project_tree_path
(
@project
,
(
@
id
))
elsif
params
[
:destination
]
==
"blob"
project_blob_path
(
@project
,
(
@
ref
+
"/"
+
params
[
:path
]
))
project_blob_path
(
@project
,
(
@
id
))
elsif
params
[
:destination
]
==
"graph"
project_graph_path
(
@project
,
@
ref
)
project_graph_path
(
@project
,
@
id
,
@options
)
else
project_commits_path
(
@project
,
@
ref
)
project_commits_path
(
@project
,
@
id
)
end
redirect_to
new_path
...
...
@@ -42,27 +40,4 @@ class RefsController < ProjectResourceController
}
end
end
protected
def
define_tree_vars
params
[
:path
]
=
nil
if
params
[
:path
].
blank?
@repo
=
project
.
repository
@commit
=
@repo
.
commit
(
@ref
)
@tree
=
Tree
.
new
(
@repo
,
@commit
.
id
,
@ref
,
params
[
:path
])
@hex_path
=
Digest
::
SHA1
.
hexdigest
(
params
[
:path
]
||
""
)
if
params
[
:path
]
@logs_path
=
logs_file_project_ref_path
(
@project
,
@ref
,
params
[
:path
])
else
@logs_path
=
logs_tree_project_ref_path
(
@project
,
@ref
)
end
rescue
return
render_404
end
def
ref
@ref
=
params
[
:id
]
||
params
[
:ref
]
end
end
app/controllers/tree_controller.rb
浏览文件 @
9ea27db1
...
...
@@ -8,9 +8,6 @@ class TreeController < ProjectResourceController
before_filter
:require_non_empty_project
def
show
@hex_path
=
Digest
::
SHA1
.
hexdigest
(
@path
)
@logs_path
=
logs_file_project_ref_path
(
@project
,
@ref
,
@path
)
respond_to
do
|
format
|
format
.
html
# Disable cache so browser history works
...
...
app/models/network/graph.rb
浏览文件 @
9ea27db1
...
...
@@ -8,10 +8,11 @@ module Network
@max_count
||=
650
end
def
initialize
project
,
ref
,
commit
def
initialize
project
,
ref
,
commit
,
filter_ref
@project
=
project
@ref
=
ref
@commit
=
commit
@filter_ref
=
filter_ref
@repo
=
project
.
repo
@commits
=
collect_commits
...
...
@@ -107,7 +108,9 @@ module Network
skip:
skip
}
Grit
::
Commit
.
find_all
(
@repo
,
nil
,
opts
)
ref
=
@ref
if
@filter_ref
Grit
::
Commit
.
find_all
(
@repo
,
ref
,
opts
)
end
def
commits_sort_by_ref
...
...
app/views/graph/_head.html.haml
浏览文件 @
9ea27db1
...
...
@@ -3,14 +3,24 @@
.clearfix
.pull-left
=
render
partial:
'shared/ref_switcher'
,
locals:
{
destination:
'graph'
,
path:
@path
}
=
render
partial:
'shared/ref_switcher'
,
locals:
{
destination:
'graph'
}
.pull-left
=
form_tag
project_graph_path
(
@project
,
@id
),
method: :get
do
|
f
|
.control-group
=
label_tag
:filter_ref
,
"Show only selected ref"
,
class:
'control-label light'
.controls
=
check_box_tag
:filter_ref
,
1
,
@options
[
:filter_ref
]
-
@options
.
each
do
|
key
,
value
|
=
hidden_field_tag
(
key
,
value
,
id:
nil
)
unless
key
==
"filter_ref"
.search.pull-right
=
form_tag
project_graph_path
(
@project
,
params
[
:id
]
),
method: :get
do
|
f
|
=
form_tag
project_graph_path
(
@project
,
@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"
=
text_field_tag
:q
,
@
options
[
:q
]
,
placeholder:
"Input SHA"
,
class:
"search-input xlarge"
=
button_tag
type:
'submit'
,
class:
'btn vtop'
do
%i
.icon-search
-
@options
.
each
do
|
key
,
value
|
=
hidden_field_tag
(
key
,
value
,
id:
nil
)
unless
key
==
"q"
app/views/graph/show.html.haml
浏览文件 @
9ea27db1
...
...
@@ -7,9 +7,11 @@
:javascript
var
branch_graph
;
$
(
"
#filter_ref
"
).
click
(
function
()
{
$
(
this
).
closest
(
'
form
'
).
submit
();
});
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
q:
@q
,
format: :json
)
}
'
,
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
@options
.
merge
(
format: :json
)
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
ref
:
'
#{
@ref
}
'
,
commit_id
:
'
#{
@commit
.
id
}
'
...
...
app/views/shared/_ref_switcher.html.haml
浏览文件 @
9ea27db1
...
...
@@ -3,3 +3,5 @@
=
hidden_field_tag
:destination
,
destination
-
if
defined?
(
path
)
=
hidden_field_tag
:path
,
path
-
@options
&&
@options
.
each
do
|
key
,
value
|
=
hidden_field_tag
key
,
value
,
id:
nil
features/project/network.feature
浏览文件 @
9ea27db1
...
...
@@ -25,3 +25,12 @@ Feature: Project Network Graph
Then
page should have network graph
And
page should select
"master"
in select box
And
page should have
"v2.1.0"
on graph
@javascript
Scenario
:
I
should filter selected tag
When
I switch ref to
"v2.1.0"
Then
page should have content not cotaining
"v2.1.0"
When
click
"Show only selected branch"
checkbox
Then
page should not have content not cotaining
"v2.1.0"
When
click
"Show only selected branch"
checkbox
Then
page should have content not cotaining
"v2.1.0"
features/steps/project/project_network_graph.rb
浏览文件 @
9ea27db1
...
...
@@ -19,6 +19,10 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
page
.
should
have_selector
'#ref_chzn span'
,
text:
"master"
end
And
'page should select "v2.1.0" in select box'
do
page
.
should
have_selector
'#ref_chzn span'
,
text:
"v2.1.0"
end
And
'page should have "master" on graph'
do
within
'.graph'
do
page
.
should
have_content
'master'
...
...
@@ -35,6 +39,28 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
sleep
2
end
When
'I switch ref to "v2.1.0"'
do
page
.
select
'v2.1.0'
,
from:
'ref'
sleep
2
end
When
'click "Show only selected branch" checkbox'
do
find
(
'#filter_ref'
).
click
sleep
2
end
Then
'page should have content not cotaining "v2.1.0"'
do
within
'.graph'
do
page
.
should
have_content
'cleaning'
end
end
Then
'page should not have content not cotaining "v2.1.0"'
do
within
'.graph'
do
page
.
should_not
have_content
'cleaning'
end
end
And
'page should select "stable" in select box'
do
page
.
should
have_selector
'#ref_chzn span'
,
text:
"stable"
end
...
...
lib/extracts_path.rb
浏览文件 @
9ea27db1
...
...
@@ -94,16 +94,33 @@ module ExtractsPath
# Automatically renders `not_found!` if a valid tree path could not be
# resolved (e.g., when a user inserts an invalid path or ref).
def
assign_ref_vars
@id
=
params
[
:id
]
@id
=
get_id
@ref
,
@path
=
extract_ref
(
@id
)
@
commit
=
@project
.
repository
.
commit
(
@ref
)
@
repo
=
@project
.
repository
@tree
=
Tree
.
new
(
@project
.
repository
,
@commit
.
id
,
@ref
,
@path
)
@commit
=
@repo
.
commit
(
@ref
)
@tree
=
Tree
.
new
(
@repo
,
@commit
.
id
,
@ref
,
@path
)
@hex_path
=
Digest
::
SHA1
.
hexdigest
(
@path
)
@logs_path
=
logs_file_project_ref_path
(
@project
,
@ref
,
@path
)
# assign allowed options
allowed_options
=
[
"filter_ref"
,
"q"
]
@options
=
params
.
select
{
|
key
,
value
|
allowed_options
.
include?
(
key
)
&&
!
value
.
blank?
}
@options
=
HashWithIndifferentAccess
.
new
(
@options
)
raise
InvalidPathError
unless
@tree
.
exists?
rescue
RuntimeError
,
NoMethodError
,
InvalidPathError
not_found!
end
private
def
get_id
id
=
params
[
:id
]
||
params
[
:ref
]
id
+=
"/"
+
params
[
:path
]
unless
params
[
:path
].
blank?
id
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录