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
81cc1cb8
Commit
81cc1cb8
authored
Feb 05, 2013
by
Sato Hiroyuki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable to display the commit older than 650th commit.
parent
1e907498
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
20 deletions
+48
-20
app/controllers/graph_controller.rb
app/controllers/graph_controller.rb
+1
-1
lib/gitlab/graph/json_builder.rb
lib/gitlab/graph/json_builder.rb
+47
-19
No files found.
app/controllers/graph_controller.rb
View file @
81cc1cb8
...
...
@@ -10,7 +10,7 @@ class GraphController < ProjectResourceController
respond_to
do
|
format
|
format
.
html
format
.
json
do
graph
=
Gitlab
::
Graph
::
JsonBuilder
.
new
(
project
,
@ref
)
graph
=
Gitlab
::
Graph
::
JsonBuilder
.
new
(
project
,
@ref
,
@commit
)
render
:json
=>
graph
.
to_json
end
end
...
...
lib/gitlab/graph/json_builder.rb
View file @
81cc1cb8
...
...
@@ -9,9 +9,10 @@ module Gitlab
@max_count
||=
650
end
def
initialize
project
,
ref
def
initialize
project
,
ref
,
commit
@project
=
project
@ref
=
ref
@commit
=
commit
@repo
=
project
.
repo
@ref_cache
=
{}
...
...
@@ -31,7 +32,8 @@ module Gitlab
# Get commits from repository
#
def
collect_commits
@commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
,
{
max_count:
self
.
class
.
max_count
}).
dup
@commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
,
{
max_count:
self
.
class
.
max_count
,
skip:
to_commit
}).
dup
# Decorate with app/models/commit.rb
@commits
.
map!
{
|
commit
|
::
Commit
.
new
(
commit
)
}
...
...
@@ -53,37 +55,24 @@ module Gitlab
#
# @return [Array<TimeDate>] list of commit dates corelated with time on commits
def
index_commits
days
,
heads
,
times
=
[],
[],
[]
days
,
times
=
[],
[]
map
=
{}
commits
.
reverse
.
each_with_index
do
|
c
,
i
|
c
.
time
=
i
days
[
i
]
=
c
.
committed_date
map
[
c
.
id
]
=
c
heads
+=
c
.
refs
unless
c
.
refs
.
nil?
times
[
i
]
=
c
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
=
{}
days
.
each_index
do
|
i
|
@_reserved
[
i
]
=
[]
end
heads
.
each
do
|
h
|
if
map
.
include?
h
.
commit
.
id
then
place_chain
(
map
[
h
.
commit
.
id
],
map
)
commits_sort_by_ref
.
each
do
|
commit
|
if
map
.
include?
commit
.
id
then
place_chain
(
map
[
commit
.
id
],
map
)
end
end
...
...
@@ -95,6 +84,45 @@ module Gitlab
days
end
# Skip count that the target commit is displayed in center.
def
to_commit
commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
)
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
)
end
heads
.
map!
do
|
head
|
head
.
name
end
heads
.
include?
(
@ref
)
end
def
find_free_parent_spaces
(
commit
,
map
,
times
)
spaces
=
[]
...
...
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