summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab/gpg/invalid_gpg_signature_updater.rb3
-rw-r--r--spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb9
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/gitlab/gpg/invalid_gpg_signature_updater.rb b/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
index 6511a8f8285..06e4823de32 100644
--- a/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
+++ b/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
@@ -10,7 +10,8 @@ module Gitlab
.where(valid_signature: false)
.where(gpg_key_primary_keyid: @gpg_key.primary_keyid)
.find_each do |gpg_signature|
- commit = Gitlab::Git::Commit.find(gpg_signature.project.repository, gpg_signature.commit_sha)
+ 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)
end
end
diff --git a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
index 42348b3f2c1..8b60b36452b 100644
--- a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
+++ b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
@@ -4,13 +4,18 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
describe '#run' do
let!(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' }
let!(:project) { create :project, :repository, path: 'sample-project' }
- let!(:commit) do
+ let!(:raw_commit) do
raw_commit = double(:raw_commit, signature: [
GpgHelpers::User1.signed_commit_signature,
GpgHelpers::User1.signed_commit_base_data
], sha: commit_sha)
+
allow(raw_commit).to receive :save!
+ raw_commit
+ end
+
+ let!(:commit) do
create :commit, git_commit: raw_commit, project: project
end
@@ -24,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(commit)
+ allow(Gitlab::Git::Commit).to receive(:find).with(kind_of(Repository), commit_sha).and_return(raw_commit)
end
context 'gpg signature did not have an associated gpg key' do