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
Léo-Paul Géneau
gitlab-ce
Commits
525a8cd3
Commit
525a8cd3
authored
Jan 29, 2013
by
Sato Hiroyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switchable the main branch on network graph
parent
c84675ee
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
22 deletions
+43
-22
app/controllers/graph_controller.rb
app/controllers/graph_controller.rb
+18
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+0
-10
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+2
-0
app/views/graph/show.html.haml
app/views/graph/show.html.haml
+5
-3
app/views/layouts/project_resource.html.haml
app/views/layouts/project_resource.html.haml
+2
-2
config/routes.rb
config/routes.rb
+1
-1
lib/extracts_path.rb
lib/extracts_path.rb
+2
-1
lib/gitlab/graph/json_builder.rb
lib/gitlab/graph/json_builder.rb
+4
-3
vendor/assets/javascripts/branch-graph.js
vendor/assets/javascripts/branch-graph.js
+9
-2
No files found.
app/controllers/graph_controller.rb
0 → 100644
View file @
525a8cd3
class
GraphController
<
ProjectResourceController
include
ExtractsPath
# Authorize
before_filter
:authorize_read_project!
before_filter
:authorize_code_access!
before_filter
:require_non_empty_project
def
show
respond_to
do
|
format
|
format
.
html
format
.
json
do
graph
=
Gitlab
::
Graph
::
JsonBuilder
.
new
(
project
,
@ref
)
render
:json
=>
graph
.
to_json
end
end
end
end
app/controllers/projects_controller.rb
View file @
525a8cd3
...
@@ -90,16 +90,6 @@ class ProjectsController < ProjectResourceController
...
@@ -90,16 +90,6 @@ class ProjectsController < ProjectResourceController
end
end
end
end
def
graph
respond_to
do
|
format
|
format
.
html
format
.
json
do
graph
=
Gitlab
::
Graph
::
JsonBuilder
.
new
(
project
)
render
:json
=>
graph
.
to_json
end
end
end
def
destroy
def
destroy
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
project
)
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
project
)
...
...
app/controllers/refs_controller.rb
View file @
525a8cd3
...
@@ -13,6 +13,8 @@ class RefsController < ProjectResourceController
...
@@ -13,6 +13,8 @@ class RefsController < ProjectResourceController
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
,
(
@ref
+
"/"
+
params
[
:path
]))
elsif
params
[
:destination
]
==
"graph"
project_graph_path
(
@project
,
@ref
)
else
else
project_commits_path
(
@project
,
@ref
)
project_commits_path
(
@project
,
@ref
)
end
end
...
...
app/views/
projects/graph
.html.haml
→
app/views/
graph/show
.html.haml
View file @
525a8cd3
%h3
.page_title
Project Network Graph
%h3
.page_title
Project Network Graph
%br
%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.
...
@@ -11,7 +12,8 @@
...
@@ -11,7 +12,8 @@
var
branch_graph
;
var
branch_graph
;
$
(
function
(){
$
(
function
(){
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
url
:
'
#{
url_for
controller:
'projects'
,
action:
'graph'
,
format: :json
}
'
,
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
format: :json
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
ref
:
'
#{
@ref
}
'
});
});
});
});
app/views/layouts/project_resource.html.haml
View file @
525a8cd3
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
=
link_to
'Files'
,
project_tree_path
(
@project
,
@ref
||
@repository
.
root_ref
)
=
link_to
'Files'
,
project_tree_path
(
@project
,
@ref
||
@repository
.
root_ref
)
=
nav_link
(
controller:
%w(commit commits compare repositories protected_branches)
)
do
=
nav_link
(
controller:
%w(commit commits compare repositories protected_branches)
)
do
=
link_to
"Commits"
,
project_commits_path
(
@project
,
@ref
||
@repository
.
root_ref
)
=
link_to
"Commits"
,
project_commits_path
(
@project
,
@ref
||
@repository
.
root_ref
)
=
nav_link
(
path:
'projects#graph'
)
do
=
nav_link
(
controller:
%w(graph)
)
do
=
link_to
"Network"
,
graph_project_path
(
@project
)
=
link_to
"Network"
,
project_graph_path
(
@project
,
@ref
||
@repository
.
root_ref
)
-
if
@project
.
issues_enabled
-
if
@project
.
issues_enabled
=
nav_link
(
controller:
%w(issues milestones labels)
)
do
=
nav_link
(
controller:
%w(issues milestones labels)
)
do
...
...
config/routes.rb
View file @
525a8cd3
...
@@ -163,7 +163,6 @@ Gitlab::Application.routes.draw do
...
@@ -163,7 +163,6 @@ Gitlab::Application.routes.draw do
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.0-9_\-\/]+/
},
except:
[
:new
,
:create
,
:index
],
path:
"/"
do
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.0-9_\-\/]+/
},
except:
[
:new
,
:create
,
:index
],
path:
"/"
do
member
do
member
do
get
"wall"
get
"wall"
get
"graph"
get
"files"
get
"files"
end
end
...
@@ -173,6 +172,7 @@ Gitlab::Application.routes.draw do
...
@@ -173,6 +172,7 @@ Gitlab::Application.routes.draw do
resources
:compare
,
only:
[
:index
,
:create
]
resources
:compare
,
only:
[
:index
,
:create
]
resources
:blame
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blame
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:graph
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
match
"/compare/:from...:to"
=>
"compare#show"
,
as:
"compare"
,
match
"/compare/:from...:to"
=>
"compare#show"
,
as:
"compare"
,
:via
=>
[
:get
,
:post
],
constraints:
{
from:
/.+/
,
to:
/.+/
}
:via
=>
[
:get
,
:post
],
constraints:
{
from:
/.+/
,
to:
/.+/
}
...
...
lib/extracts_path.rb
View file @
525a8cd3
...
@@ -54,9 +54,10 @@ module ExtractsPath
...
@@ -54,9 +54,10 @@ module ExtractsPath
input
.
gsub!
(
/^
#{
Gitlab
.
config
.
gitlab
.
relative_url_root
}
/
,
""
)
input
.
gsub!
(
/^
#{
Gitlab
.
config
.
gitlab
.
relative_url_root
}
/
,
""
)
# Remove project, actions and all other staff from path
# Remove project, actions and all other staff from path
input
.
gsub!
(
/^\/
#{
Regexp
.
escape
(
@project
.
path_with_namespace
)
}
/
,
""
)
input
.
gsub!
(
/^\/
#{
Regexp
.
escape
(
@project
.
path_with_namespace
)
}
/
,
""
)
input
.
gsub!
(
/^\/(tree|commits|blame|blob|refs)\//
,
""
)
# remove actions
input
.
gsub!
(
/^\/(tree|commits|blame|blob|refs
|graph
)\//
,
""
)
# remove actions
input
.
gsub!
(
/\?.*$/
,
""
)
# remove stamps suffix
input
.
gsub!
(
/\?.*$/
,
""
)
# remove stamps suffix
input
.
gsub!
(
/.atom$/
,
""
)
# remove rss feed
input
.
gsub!
(
/.atom$/
,
""
)
# remove rss feed
input
.
gsub!
(
/.json$/
,
""
)
# remove json suffix
input
.
gsub!
(
/\/edit$/
,
""
)
# remove edit route part
input
.
gsub!
(
/\/edit$/
,
""
)
# remove edit route part
if
input
.
match
(
/^([[:alnum:]]{40})(.+)/
)
if
input
.
match
(
/^([[:alnum:]]{40})(.+)/
)
...
...
lib/gitlab/graph/json_builder.rb
View file @
525a8cd3
...
@@ -9,8 +9,9 @@ module Gitlab
...
@@ -9,8 +9,9 @@ module Gitlab
@max_count
||=
650
@max_count
||=
650
end
end
def
initialize
project
def
initialize
project
,
ref
@project
=
project
@project
=
project
@ref
=
ref
@repo
=
project
.
repo
@repo
=
project
.
repo
@ref_cache
=
{}
@ref_cache
=
{}
...
@@ -66,9 +67,9 @@ module Gitlab
...
@@ -66,9 +67,9 @@ module Gitlab
heads
.
select!
{
|
h
|
h
.
is_a?
Grit
::
Head
or
h
.
is_a?
Grit
::
Remote
}
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
# sort heads so the master is top and current branches are closer
heads
.
sort!
do
|
a
,
b
|
heads
.
sort!
do
|
a
,
b
|
if
a
.
name
==
"master"
if
a
.
name
==
@ref
-
1
-
1
elsif
b
.
name
==
"master"
elsif
b
.
name
==
@ref
1
1
else
else
b
.
commit
.
committed_date
<=>
a
.
commit
.
committed_date
b
.
commit
.
committed_date
<=>
a
.
commit
.
committed_date
...
...
vendor/assets/javascripts/branch-graph.js
View file @
525a8cd3
...
@@ -73,7 +73,8 @@
...
@@ -73,7 +73,8 @@
,
cumonth
=
""
,
cumonth
=
""
,
offsetX
=
20
,
offsetX
=
20
,
offsetY
=
60
,
offsetY
=
60
,
barWidth
=
Math
.
max
(
graphWidth
,
this
.
dayCount
*
20
+
320
);
,
barWidth
=
Math
.
max
(
graphWidth
,
this
.
dayCount
*
20
+
320
)
,
scrollLeft
=
cw
;
this
.
raphael
=
r
;
this
.
raphael
=
r
;
...
@@ -145,12 +146,18 @@
...
@@ -145,12 +146,18 @@
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
;
}
}
}
this
.
appendAnchor
(
top
,
this
.
commits
[
i
],
x
,
y
);
this
.
appendAnchor
(
top
,
this
.
commits
[
i
],
x
,
y
);
}
}
top
.
toFront
();
top
.
toFront
();
this
.
element
.
scrollLeft
(
cw
);
this
.
element
.
scrollLeft
(
scrollLeft
);
this
.
bindEvents
();
this
.
bindEvents
();
};
};
...
...
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