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
49dd62ad
Commit
49dd62ad
authored
Nov 28, 2017
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate Gitlab::Git::Commit.shas_with_signatures
- Added tests for Git::Commit.shas_with_signatures
parent
29be9c1a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
5 deletions
+60
-5
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+11
-5
lib/gitlab/gitaly_client/commit_service.rb
lib/gitlab/gitaly_client/commit_service.rb
+20
-0
spec/lib/gitlab/git/commit_spec.rb
spec/lib/gitlab/git/commit_spec.rb
+29
-0
No files found.
lib/gitlab/git/commit.rb
View file @
49dd62ad
...
@@ -213,11 +213,17 @@ module Gitlab
...
@@ -213,11 +213,17 @@ module Gitlab
end
end
def
shas_with_signatures
(
repository
,
shas
)
def
shas_with_signatures
(
repository
,
shas
)
shas
.
select
do
|
sha
|
GitalyClient
.
migrate
(
:filter_shas_with_signatures
)
do
|
is_enabled
|
begin
if
is_enabled
Rugged
::
Commit
.
extract_signature
(
repository
.
rugged
,
sha
)
Gitlab
::
GitalyClient
::
CommitService
.
new
(
repository
).
filter_shas_with_signatures
(
shas
)
rescue
Rugged
::
OdbError
else
false
shas
.
select
do
|
sha
|
begin
Rugged
::
Commit
.
extract_signature
(
repository
.
rugged
,
sha
)
rescue
Rugged
::
OdbError
false
end
end
end
end
end
end
end
end
...
...
lib/gitlab/gitaly_client/commit_service.rb
View file @
49dd62ad
...
@@ -250,6 +250,26 @@ module Gitlab
...
@@ -250,6 +250,26 @@ module Gitlab
consume_commits_response
(
response
)
consume_commits_response
(
response
)
end
end
def
filter_shas_with_signatures
(
shas
)
request
=
Gitaly
::
FilterShasWithSignaturesRequest
.
new
(
repository:
@gitaly_repo
)
enum
=
Enumerator
.
new
do
|
y
|
shas
.
each_slice
(
20
)
do
|
revs
|
request
.
shas
=
GitalyClient
.
encode_repeated
(
revs
)
y
.
yield
request
request
=
Gitaly
::
FilterShasWithSignaturesRequest
.
new
end
end
response
=
GitalyClient
.
call
(
@repository
.
storage
,
:commit_service
,
:filter_shas_with_signatures
,
enum
)
response
.
flat_map
do
|
msg
|
msg
.
shas
.
map
{
|
sha
|
EncodingHelper
.
encode!
(
sha
)
}
end
end
private
private
def
call_commit_diff
(
request_params
,
options
=
{})
def
call_commit_diff
(
request_params
,
options
=
{})
...
...
spec/lib/gitlab/git/commit_spec.rb
View file @
49dd62ad
...
@@ -278,6 +278,35 @@ describe Gitlab::Git::Commit, seed_helper: true do
...
@@ -278,6 +278,35 @@ describe Gitlab::Git::Commit, seed_helper: true do
it
{
is_expected
.
not_to
include
(
SeedRepo
::
FirstCommit
::
ID
)
}
it
{
is_expected
.
not_to
include
(
SeedRepo
::
FirstCommit
::
ID
)
}
end
end
shared_examples
'.shas_with_signatures'
do
let
(
:signed_shas
)
{
%w[5937ac0a7beb003549fc5fd26fc247adbce4a52e 570e7b2abdd848b95f2f578043fc23bd6f6fd24d]
}
let
(
:unsigned_shas
)
{
%w[19e2e9b4ef76b422ce1154af39a91323ccc57434 c642fe9b8b9f28f9225d7ea953fe14e74748d53b]
}
let
(
:first_signed_shas
)
{
%w[5937ac0a7beb003549fc5fd26fc247adbce4a52e c642fe9b8b9f28f9225d7ea953fe14e74748d53b]
}
it
'has 2 signed shas'
do
ret
=
described_class
.
shas_with_signatures
(
repository
,
signed_shas
)
expect
(
ret
).
to
eq
(
signed_shas
)
end
it
'has 0 signed shas'
do
ret
=
described_class
.
shas_with_signatures
(
repository
,
unsigned_shas
)
expect
(
ret
).
to
eq
([])
end
it
'has 1 signed sha'
do
ret
=
described_class
.
shas_with_signatures
(
repository
,
first_signed_shas
)
expect
(
ret
).
to
contain_exactly
(
first_signed_shas
.
first
)
end
end
describe
'.shas_with_signatures with gitaly on'
do
it_should_behave_like
'.shas_with_signatures'
end
describe
'.shas_with_signatures with gitaly disabled'
,
:disable_gitaly
do
it_should_behave_like
'.shas_with_signatures'
end
describe
'.find_all'
do
describe
'.find_all'
do
shared_examples
'finding all commits'
do
shared_examples
'finding all commits'
do
it
'should return a return a collection of commits'
do
it
'should return a return a collection of commits'
do
...
...
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