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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
d04ad4cb
Commit
d04ad4cb
authored
Aug 20, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4812 from hiroponz/remove-dependancy-of-grit
Remove the dependancy of grit from class Network::Graph
parents
27e532b4
fd0afcc9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
35 deletions
+11
-35
app/helpers/graph_helper.rb
app/helpers/graph_helper.rb
+2
-2
app/models/network/commit.rb
app/models/network/commit.rb
+2
-4
app/models/network/graph.rb
app/models/network/graph.rb
+6
-28
app/views/projects/network/show.json.erb
app/views/projects/network/show.json.erb
+1
-1
No files found.
app/helpers/graph_helper.rb
View file @
d04ad4cb
module
GraphHelper
module
GraphHelper
def
get_refs
(
commit
)
def
get_refs
(
repo
,
commit
)
refs
=
""
refs
=
""
refs
+=
commit
.
ref
s
.
collect
{
|
r
|
r
.
name
}.
join
(
" "
)
if
commit
.
refs
refs
+=
commit
.
ref
_names
(
repo
).
join
(
" "
)
# append note count
# append note count
refs
+=
"[
#{
@graph
.
notes
[
commit
.
id
]
}
]"
if
@graph
.
notes
[
commit
.
id
]
>
0
refs
+=
"[
#{
@graph
.
notes
[
commit
.
id
]
}
]"
if
@graph
.
notes
[
commit
.
id
]
>
0
...
...
app/models/network/commit.rb
View file @
d04ad4cb
...
@@ -4,15 +4,13 @@ module Network
...
@@ -4,15 +4,13 @@ module Network
class
Commit
class
Commit
include
ActionView
::
Helpers
::
TagHelper
include
ActionView
::
Helpers
::
TagHelper
attr_reader
:refs
attr_accessor
:time
,
:spaces
,
:parent_spaces
attr_accessor
:time
,
:spaces
,
:parent_spaces
def
initialize
(
raw_commit
,
refs
)
def
initialize
(
raw_commit
)
@commit
=
Gitlab
::
Git
::
Commit
.
new
(
raw_commit
)
@commit
=
raw_commit
@time
=
-
1
@time
=
-
1
@spaces
=
[]
@spaces
=
[]
@parent_spaces
=
[]
@parent_spaces
=
[]
@refs
=
refs
||
[]
end
end
def
method_missing
(
m
,
*
args
,
&
block
)
def
method_missing
(
m
,
*
args
,
&
block
)
...
...
app/models/network/graph.rb
View file @
d04ad4cb
require
"grit"
module
Network
module
Network
class
Graph
class
Graph
attr_reader
:days
,
:commits
,
:map
,
:notes
attr_reader
:days
,
:commits
,
:map
,
:notes
,
:repo
def
self
.
max_count
def
self
.
max_count
@max_count
||=
650
@max_count
||=
650
...
@@ -13,7 +11,7 @@ module Network
...
@@ -13,7 +11,7 @@ module Network
@ref
=
ref
@ref
=
ref
@commit
=
commit
@commit
=
commit
@filter_ref
=
filter_ref
@filter_ref
=
filter_ref
@repo
=
project
.
repo
@repo
=
project
.
repo
sitory
@commits
=
collect_commits
@commits
=
collect_commits
@days
=
index_commits
@days
=
index_commits
...
@@ -33,11 +31,9 @@ module Network
...
@@ -33,11 +31,9 @@ module Network
# Get commits from repository
# Get commits from repository
#
#
def
collect_commits
def
collect_commits
refs_cache
=
build_refs_cache
find_commits
(
count_to_display_commit_in_center
).
map
do
|
commit
|
find_commits
(
count_to_display_commit_in_center
).
map
do
|
commit
|
# Decorate with app/model/network/commit.rb
# Decorate with app/model/network/commit.rb
Network
::
Commit
.
new
(
commit
,
refs_cache
[
commit
.
id
]
)
Network
::
Commit
.
new
(
commit
)
end
end
end
end
...
@@ -103,14 +99,13 @@ module Network
...
@@ -103,14 +99,13 @@ module Network
def
find_commits
(
skip
=
0
)
def
find_commits
(
skip
=
0
)
opts
=
{
opts
=
{
date_order:
true
,
max_count:
self
.
class
.
max_count
,
max_count:
self
.
class
.
max_count
,
skip:
skip
skip:
skip
}
}
ref
=
@ref
if
@filter_ref
opts
[
:ref
]
=
@commit
.
id
if
@filter_ref
Grit
::
Commit
.
find_all
(
@repo
,
ref
,
opts
)
@repo
.
find_commits
(
opts
)
end
end
def
commits_sort_by_ref
def
commits_sort_by_ref
...
@@ -126,15 +121,7 @@ module Network
...
@@ -126,15 +121,7 @@ module Network
end
end
def
include_ref?
(
commit
)
def
include_ref?
(
commit
)
heads
=
commit
.
refs
.
select
do
|
ref
|
commit
.
ref_names
(
@repo
).
include?
(
@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
end
def
find_free_parent_spaces
(
commit
)
def
find_free_parent_spaces
(
commit
)
...
@@ -282,14 +269,5 @@ module Network
...
@@ -282,14 +269,5 @@ module Network
leaves
.
push
(
commit
)
leaves
.
push
(
commit
)
end
end
end
end
def
build_refs_cache
refs_cache
=
{}
@repo
.
refs
.
each
do
|
ref
|
refs_cache
[
ref
.
commit
.
id
]
=
[]
unless
refs_cache
.
include?
(
ref
.
commit
.
id
)
refs_cache
[
ref
.
commit
.
id
]
<<
ref
end
refs_cache
end
end
end
end
end
app/views/projects/network/show.json.erb
View file @
d04ad4cb
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
},
},
time:
c
.
time
,
time:
c
.
time
,
space:
c
.
spaces
.
first
,
space:
c
.
spaces
.
first
,
refs:
get_refs
(
c
),
refs:
get_refs
(
@graph
.
repo
,
c
),
id:
c
.
sha
,
id:
c
.
sha
,
date:
c
.
date
,
date:
c
.
date
,
message:
c
.
message
,
message:
c
.
message
,
...
...
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