Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
9ea27db1
Commit
9ea27db1
authored
May 13, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3591 from hiroponz/show-only-selected-branch
Show only selected branch
parents
58d6176b
1738055d
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
87 additions
and
52 deletions
+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
No files found.
app/controllers/graph_controller.rb
View file @
9ea27db1
...
@@ -8,21 +8,15 @@ class GraphController < ProjectResourceController
...
@@ -8,21 +8,15 @@ class GraphController < ProjectResourceController
before_filter
:require_non_empty_project
before_filter
:require_non_empty_project
def
show
def
show
if
params
.
has_key?
(
:q
)
if
@options
[
:q
]
if
params
[
:q
].
blank?
@commit
=
@project
.
repository
.
commit
(
@options
[
:q
])
||
@commit
redirect_to
project_graph_path
(
@project
,
params
[
:id
])
return
end
@q
=
params
[
:q
]
@commit
=
@project
.
repository
.
commit
(
@q
)
||
@commit
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
do
format
.
json
do
@graph
=
Network
::
Graph
.
new
(
project
,
@ref
,
@commit
)
@graph
=
Network
::
Graph
.
new
(
project
,
@ref
,
@commit
,
@options
[
:filter_ref
]
)
end
end
end
end
end
end
...
...
app/controllers/refs_controller.rb
View file @
9ea27db1
class
RefsController
<
ProjectResourceController
class
RefsController
<
ProjectResourceController
include
ExtractsPath
# Authorize
# Authorize
before_filter
:authorize_read_project!
before_filter
:authorize_read_project!
before_filter
:authorize_code_access!
before_filter
:authorize_code_access!
before_filter
:require_non_empty_project
before_filter
:require_non_empty_project
before_filter
:ref
before_filter
:define_tree_vars
,
only:
[
:blob
,
:logs_tree
]
def
switch
def
switch
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
new_path
=
if
params
[
:destination
]
==
"tree"
new_path
=
if
params
[
:destination
]
==
"tree"
project_tree_path
(
@project
,
(
@
ref
+
"/"
+
params
[
:path
]
))
project_tree_path
(
@project
,
(
@
id
))
elsif
params
[
:destination
]
==
"blob"
elsif
params
[
:destination
]
==
"blob"
project_blob_path
(
@project
,
(
@
ref
+
"/"
+
params
[
:path
]
))
project_blob_path
(
@project
,
(
@
id
))
elsif
params
[
:destination
]
==
"graph"
elsif
params
[
:destination
]
==
"graph"
project_graph_path
(
@project
,
@
ref
)
project_graph_path
(
@project
,
@
id
,
@options
)
else
else
project_commits_path
(
@project
,
@
ref
)
project_commits_path
(
@project
,
@
id
)
end
end
redirect_to
new_path
redirect_to
new_path
...
@@ -42,27 +40,4 @@ class RefsController < ProjectResourceController
...
@@ -42,27 +40,4 @@ class RefsController < ProjectResourceController
}
}
end
end
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
end
app/controllers/tree_controller.rb
View file @
9ea27db1
...
@@ -8,9 +8,6 @@ class TreeController < ProjectResourceController
...
@@ -8,9 +8,6 @@ class TreeController < ProjectResourceController
before_filter
:require_non_empty_project
before_filter
:require_non_empty_project
def
show
def
show
@hex_path
=
Digest
::
SHA1
.
hexdigest
(
@path
)
@logs_path
=
logs_file_project_ref_path
(
@project
,
@ref
,
@path
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
# Disable cache so browser history works
# Disable cache so browser history works
...
...
app/models/network/graph.rb
View file @
9ea27db1
...
@@ -8,10 +8,11 @@ module Network
...
@@ -8,10 +8,11 @@ module Network
@max_count
||=
650
@max_count
||=
650
end
end
def
initialize
project
,
ref
,
commit
def
initialize
project
,
ref
,
commit
,
filter_ref
@project
=
project
@project
=
project
@ref
=
ref
@ref
=
ref
@commit
=
commit
@commit
=
commit
@filter_ref
=
filter_ref
@repo
=
project
.
repo
@repo
=
project
.
repo
@commits
=
collect_commits
@commits
=
collect_commits
...
@@ -107,7 +108,9 @@ module Network
...
@@ -107,7 +108,9 @@ module Network
skip:
skip
skip:
skip
}
}
Grit
::
Commit
.
find_all
(
@repo
,
nil
,
opts
)
ref
=
@ref
if
@filter_ref
Grit
::
Commit
.
find_all
(
@repo
,
ref
,
opts
)
end
end
def
commits_sort_by_ref
def
commits_sort_by_ref
...
...
app/views/graph/_head.html.haml
View file @
9ea27db1
...
@@ -3,14 +3,24 @@
...
@@ -3,14 +3,24 @@
.clearfix
.clearfix
.pull-left
.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
.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
.control-group
=
label_tag
:search
,
"Looking for commit:"
,
class:
'control-label light'
=
label_tag
:search
,
"Looking for commit:"
,
class:
'control-label light'
.controls
.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
=
button_tag
type:
'submit'
,
class:
'btn vtop'
do
%i
.icon-search
%i
.icon-search
-
@options
.
each
do
|
key
,
value
|
=
hidden_field_tag
(
key
,
value
,
id:
nil
)
unless
key
==
"q"
app/views/graph/show.html.haml
View file @
9ea27db1
...
@@ -7,9 +7,11 @@
...
@@ -7,9 +7,11 @@
:javascript
:javascript
var
branch_graph
;
var
branch_graph
;
$
(
"
#filter_ref
"
).
click
(
function
()
{
$
(
this
).
closest
(
'
form
'
).
submit
();
});
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
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"
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
ref
:
'
#{
@ref
}
'
,
ref
:
'
#{
@ref
}
'
,
commit_id
:
'
#{
@commit
.
id
}
'
commit_id
:
'
#{
@commit
.
id
}
'
...
...
app/views/shared/_ref_switcher.html.haml
View file @
9ea27db1
...
@@ -3,3 +3,5 @@
...
@@ -3,3 +3,5 @@
=
hidden_field_tag
:destination
,
destination
=
hidden_field_tag
:destination
,
destination
-
if
defined?
(
path
)
-
if
defined?
(
path
)
=
hidden_field_tag
:path
,
path
=
hidden_field_tag
:path
,
path
-
@options
&&
@options
.
each
do
|
key
,
value
|
=
hidden_field_tag
key
,
value
,
id:
nil
features/project/network.feature
View file @
9ea27db1
...
@@ -25,3 +25,12 @@ Feature: Project Network Graph
...
@@ -25,3 +25,12 @@ Feature: Project Network Graph
Then
page should have network graph
Then
page should have network graph
And
page should select
"master"
in select box
And
page should select
"master"
in select box
And
page should have
"v2.1.0"
on graph
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
View file @
9ea27db1
...
@@ -19,6 +19,10 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
...
@@ -19,6 +19,10 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
page
.
should
have_selector
'#ref_chzn span'
,
text:
"master"
page
.
should
have_selector
'#ref_chzn span'
,
text:
"master"
end
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
And
'page should have "master" on graph'
do
within
'.graph'
do
within
'.graph'
do
page
.
should
have_content
'master'
page
.
should
have_content
'master'
...
@@ -35,6 +39,28 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
...
@@ -35,6 +39,28 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
sleep
2
sleep
2
end
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
And
'page should select "stable" in select box'
do
page
.
should
have_selector
'#ref_chzn span'
,
text:
"stable"
page
.
should
have_selector
'#ref_chzn span'
,
text:
"stable"
end
end
...
...
lib/extracts_path.rb
View file @
9ea27db1
...
@@ -94,16 +94,33 @@ module ExtractsPath
...
@@ -94,16 +94,33 @@ module ExtractsPath
# Automatically renders `not_found!` if a valid tree path could not be
# Automatically renders `not_found!` if a valid tree path could not be
# resolved (e.g., when a user inserts an invalid path or ref).
# resolved (e.g., when a user inserts an invalid path or ref).
def
assign_ref_vars
def
assign_ref_vars
@id
=
params
[
:id
]
@id
=
get_id
@ref
,
@path
=
extract_ref
(
@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?
raise
InvalidPathError
unless
@tree
.
exists?
rescue
RuntimeError
,
NoMethodError
,
InvalidPathError
rescue
RuntimeError
,
NoMethodError
,
InvalidPathError
not_found!
not_found!
end
end
private
def
get_id
id
=
params
[
:id
]
||
params
[
:ref
]
id
+=
"/"
+
params
[
:path
]
unless
params
[
:path
].
blank?
id
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment