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
a7d2ebe5
Commit
a7d2ebe5
authored
Jul 06, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify fetching of commit
parent
4f7ba8f2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
4 deletions
+19
-4
app/models/gpg_signature.rb
app/models/gpg_signature.rb
+4
-0
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
+1
-3
spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
+1
-1
spec/models/gpg_signature_spec.rb
spec/models/gpg_signature_spec.rb
+13
-0
No files found.
app/models/gpg_signature.rb
View file @
a7d2ebe5
...
...
@@ -5,4 +5,8 @@ class GpgSignature < ActiveRecord::Base
validates
:commit_sha
,
presence:
true
validates
:project
,
presence:
true
validates
:gpg_key_primary_keyid
,
presence:
true
def
commit
project
.
commit
(
commit_sha
)
end
end
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
View file @
a7d2ebe5
...
...
@@ -10,9 +10,7 @@ module Gitlab
.
where
(
valid_signature:
false
)
.
where
(
gpg_key_primary_keyid:
@gpg_key
.
primary_keyid
)
.
find_each
do
|
gpg_signature
|
raw_commit
=
Gitlab
::
Git
::
Commit
.
find
(
gpg_signature
.
project
.
repository
,
gpg_signature
.
commit_sha
)
commit
=
::
Commit
.
new
(
raw_commit
,
gpg_signature
.
project
)
Gitlab
::
Gpg
::
Commit
.
new
(
commit
).
update_signature!
(
gpg_signature
)
Gitlab
::
Gpg
::
Commit
.
new
(
gpg_signature
.
commit
).
update_signature!
(
gpg_signature
)
end
end
end
...
...
spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
View file @
a7d2ebe5
...
...
@@ -29,7 +29,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
end
before
do
allow
(
Gitlab
::
Git
::
Commit
).
to
receive
(
:find
).
with
(
kind_of
(
Repository
),
commit_sha
).
and_return
(
raw_
commit
)
allow
_any_instance_of
(
GpgSignature
).
to
receive
(
:commit
).
and_return
(
commit
)
end
context
'gpg signature did not have an associated gpg key'
do
...
...
spec/models/gpg_signature_spec.rb
View file @
a7d2ebe5
...
...
@@ -12,4 +12,17 @@ RSpec.describe GpgSignature do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:gpg_key_primary_keyid
)
}
end
describe
'#commit'
do
it
'fetches the commit through the project'
do
commit_sha
=
'0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33'
project
=
create
:project
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
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