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
4aa2deb4
Commit
4aa2deb4
authored
Oct 07, 2017
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error with GPG signature updater when commit was deleted
parent
2ef28db9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
app/models/gpg_signature.rb
app/models/gpg_signature.rb
+2
-0
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
+1
-1
spec/models/gpg_signature_spec.rb
spec/models/gpg_signature_spec.rb
+22
-6
No files found.
app/models/gpg_signature.rb
View file @
4aa2deb4
...
...
@@ -60,6 +60,8 @@ class GpgSignature < ActiveRecord::Base
end
def
gpg_commit
return
unless
commit
Gitlab
::
Gpg
::
Commit
.
new
(
commit
)
end
end
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
View file @
4aa2deb4
...
...
@@ -10,7 +10,7 @@ module Gitlab
.
select
(
:id
,
:commit_sha
,
:project_id
)
.
where
(
'gpg_key_id IS NULL OR verification_status <> ?'
,
GpgSignature
.
verification_statuses
[
:verified
])
.
where
(
gpg_key_primary_keyid:
@gpg_key
.
keyids
)
.
find_each
{
|
sig
|
sig
.
gpg_commit
.
update_signature!
(
sig
)
}
.
find_each
{
|
sig
|
sig
.
gpg_commit
&
.
update_signature!
(
sig
)
}
end
end
end
...
...
spec/models/gpg_signature_spec.rb
View file @
4aa2deb4
require
'rails_helper'
RSpec
.
describe
GpgSignature
do
let
(
:commit_sha
)
{
'0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33'
}
let!
(
:project
)
{
create
(
:project
,
:repository
,
path:
'sample-project'
)
}
let!
(
:commit
)
{
create
(
:commit
,
project:
project
,
sha:
commit_sha
)
}
let
(
:gpg_signature
)
{
create
(
:gpg_signature
,
commit_sha:
commit_sha
)
}
let
(
:gpg_key
)
{
create
(
:gpg_key
)
}
let
(
:gpg_key_subkey
)
{
create
(
:gpg_key_subkey
)
}
...
...
@@ -19,11 +23,6 @@ RSpec.describe GpgSignature do
describe
'#commit'
do
it
'fetches the commit through the project'
do
commit_sha
=
'0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33'
project
=
create
:project
,
:repository
commit
=
create
:commit
,
project:
project
gpg_signature
=
create
:gpg_signature
,
commit_sha:
commit_sha
expect_any_instance_of
(
Project
).
to
receive
(
:commit
).
with
(
commit_sha
).
and_return
(
commit
)
gpg_signature
.
commit
...
...
@@ -44,11 +43,28 @@ RSpec.describe GpgSignature do
end
it
'clears gpg_key and gpg_key_subkey_id when passing nil'
do
gpg_signature
=
create
(
:gpg_signature
,
gpg_key:
gpg_key_subkey
)
gpg_signature
.
update_attribute
(
:gpg_key
,
nil
)
expect
(
gpg_signature
.
gpg_key_id
).
to
be_nil
expect
(
gpg_signature
.
gpg_key_subkey_id
).
to
be_nil
end
end
describe
'#gpg_commit'
do
context
'when commit does not exist'
do
it
'returns nil'
do
allow
(
gpg_signature
).
to
receive
(
:commit
).
and_return
(
nil
)
expect
(
gpg_signature
.
gpg_commit
).
to
be_nil
end
end
context
'when commit exists'
do
it
'returns an instance of Gitlab::Gpg::Commit'
do
allow
(
gpg_signature
).
to
receive
(
:commit
).
and_return
(
commit
)
expect
(
gpg_signature
.
gpg_commit
).
to
be_an_instance_of
(
Gitlab
::
Gpg
::
Commit
)
end
end
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