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
Boxiang Sun
gitlab-ce
Commits
29477fc2
Commit
29477fc2
authored
Jul 18, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-rev-list-removal' into 'master'
Remove RevList class See merge request gitlab-org/gitlab-ce!20087
parents
4736e051
9348efc6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
105 deletions
+67
-105
app/models/repository.rb
app/models/repository.rb
+2
-5
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+15
-0
lib/gitlab/git/rev_list.rb
lib/gitlab/git/rev_list.rb
+0
-50
lib/gitlab/gitaly_client/ref_service.rb
lib/gitlab/gitaly_client/ref_service.rb
+19
-0
spec/lib/gitlab/git/rev_list_spec.rb
spec/lib/gitlab/git/rev_list_spec.rb
+0
-35
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+31
-15
No files found.
app/models/repository.rb
View file @
29477fc2
...
...
@@ -154,12 +154,9 @@ class Repository
# Returns a list of commits that are not present in any reference
def
new_commits
(
newrev
)
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/1233
refs
=
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
::
Gitlab
::
Git
::
RevList
.
new
(
raw
,
newrev:
newrev
).
new_refs
end
commits
=
raw
.
new_commits
(
newrev
)
refs
.
map
{
|
sha
|
commit
(
sha
.
strip
)
}
::
Commit
.
decorate
(
commits
,
project
)
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/384
...
...
lib/gitlab/git/repository.rb
View file @
29477fc2
...
...
@@ -381,6 +381,21 @@ module Gitlab
end
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/1233
def
new_commits
(
newrev
)
gitaly_migrate
(
:new_commits
)
do
|
is_enabled
|
if
is_enabled
gitaly_ref_client
.
list_new_commits
(
newrev
)
else
refs
=
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
rev_list
(
including:
newrev
,
excluding: :all
).
split
(
"
\n
"
).
map
(
&
:strip
)
end
Gitlab
::
Git
::
Commit
.
batch_by_oid
(
self
,
refs
)
end
end
end
def
count_commits
(
options
)
options
=
process_count_commits_options
(
options
.
dup
)
...
...
lib/gitlab/git/rev_list.rb
deleted
100644 → 0
View file @
4736e051
module
Gitlab
module
Git
class
RevList
include
Gitlab
::
Git
::
Popen
attr_reader
:oldrev
,
:newrev
,
:repository
def
initialize
(
repository
,
newrev
:,
oldrev:
nil
)
@oldrev
=
oldrev
@newrev
=
newrev
@repository
=
repository
end
# This method returns an array of new commit references
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/1233
#
def
new_refs
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
repository
.
rev_list
(
including:
newrev
,
excluding: :all
).
split
(
"
\n
"
)
end
end
private
def
execute
(
args
)
repository
.
rev_list
(
args
).
split
(
"
\n
"
)
end
def
get_objects
(
including:
[],
excluding:
[],
options:
[],
require_path:
nil
)
opts
=
{
including:
including
,
excluding:
excluding
,
options:
options
,
objects:
true
}
repository
.
rev_list
(
opts
)
do
|
lazy_output
|
objects
=
objects_from_output
(
lazy_output
,
require_path:
require_path
)
yield
(
objects
)
end
end
def
objects_from_output
(
object_output
,
require_path:
nil
)
object_output
.
map
do
|
output_line
|
sha
,
path
=
output_line
.
split
(
' '
,
2
)
next
if
require_path
&&
path
.
to_s
.
empty?
sha
end
.
reject
(
&
:nil?
)
end
end
end
end
lib/gitlab/gitaly_client/ref_service.rb
View file @
29477fc2
...
...
@@ -56,6 +56,25 @@ module Gitlab
encode!
(
response
.
name
.
dup
)
end
def
list_new_commits
(
newrev
)
request
=
Gitaly
::
ListNewCommitsRequest
.
new
(
repository:
@gitaly_repo
,
commit_id:
newrev
)
response
=
GitalyClient
.
call
(
@storage
,
:ref_service
,
:list_new_commits
,
request
,
timeout:
GitalyClient
.
medium_timeout
)
commits
=
[]
response
.
each
do
|
msg
|
msg
.
commits
.
each
do
|
c
|
commits
<<
Gitlab
::
Git
::
Commit
.
new
(
@repository
,
c
)
end
end
commits
end
def
count_tag_names
tag_names
.
count
end
...
...
spec/lib/gitlab/git/rev_list_spec.rb
deleted
100644 → 0
View file @
4736e051
require
'spec_helper'
describe
Gitlab
::
Git
::
RevList
do
let
(
:repository
)
{
create
(
:project
,
:repository
).
repository
.
raw
}
let
(
:rev_list
)
{
described_class
.
new
(
repository
,
newrev:
'newrev'
)
}
def
args_for_popen
(
args_list
)
[
Gitlab
.
config
.
git
.
bin_path
,
'rev-list'
,
*
args_list
]
end
def
stub_popen_rev_list
(
*
additional_args
,
with_lazy_block:
true
,
output
:)
repo_path
=
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
{
repository
.
path
}
params
=
[
args_for_popen
(
additional_args
),
repo_path
,
{},
hash_including
(
lazy_block:
with_lazy_block
?
anything
:
nil
)
]
expect
(
repository
).
to
receive
(
:popen
).
with
(
*
params
)
do
|*
_
,
lazy_block
:|
output
=
lazy_block
.
call
(
output
.
lines
.
lazy
.
map
(
&
:chomp
))
if
with_lazy_block
[
output
,
0
]
end
end
context
"#new_refs"
do
it
'calls out to `popen`'
do
stub_popen_rev_list
(
'newrev'
,
'--not'
,
'--all'
,
with_lazy_block:
false
,
output:
"sha1
\n
sha2"
)
expect
(
rev_list
.
new_refs
).
to
eq
(
%w[sha1 sha2]
)
end
end
end
spec/models/repository_spec.rb
View file @
29477fc2
...
...
@@ -296,24 +296,40 @@ describe Repository do
end
describe
'#new_commits'
do
let
(
:new_refs
)
do
double
(
:git_rev_list
,
new_refs:
%w[
c1acaa58bbcbc3eafe538cb8274ba387047b69f8
5937ac0a7beb003549fc5fd26fc247adbce4a52e
]
)
end
shared_examples
'finding unreferenced commits'
do
set
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
it
'delegates to Gitlab::Git::RevList'
do
expect
(
Gitlab
::
Git
::
RevList
).
to
receive
(
:new
).
with
(
repository
.
raw
,
newrev:
'aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj'
).
and_return
(
new_refs
)
subject
{
repository
.
new_commits
(
rev
)
}
commits
=
repository
.
new_commits
(
'aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj'
)
context
'when there are no new commits'
do
let
(
:rev
)
{
repository
.
commit
.
id
}
expect
(
commits
).
to
eq
([
repository
.
commit
(
'c1acaa58bbcbc3eafe538cb8274ba387047b69f8'
),
repository
.
commit
(
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
)
])
it
'returns an empty array'
do
expect
(
subject
).
to
eq
([])
end
end
context
'when new commits are found'
do
let
(
:branch
)
{
'orphaned-branch'
}
let!
(
:rev
)
{
repository
.
commit
(
branch
).
id
}
it
'returns the commits'
do
repository
.
delete_branch
(
branch
)
expect
(
subject
).
not_to
be_empty
expect
(
subject
).
to
all
(
be_a
(
::
Commit
)
)
expect
(
subject
.
size
).
to
eq
(
1
)
end
end
end
context
'when Gitaly handles the request'
do
it_behaves_like
'finding unreferenced commits'
end
context
'when Gitaly is disabled'
,
:disable_gitaly
do
it_behaves_like
'finding unreferenced commits'
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