Commit 5fc11a16 authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'test_update_merge_request_worker_performance' into 'master'

Memoize force_push for a push

See merge request gitlab-org/gitlab!53536
parents 057b01c1 167c8141
---
title: Speed up update merge request worker by memoizing whether a push is a force or not
merge_request: 53536
author:
type: performance
......@@ -33,7 +33,9 @@ module Gitlab
end
def force_push?
Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev)
strong_memoize(:force_push) do
Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev)
end
end
def branch_push?
......
......@@ -86,6 +86,16 @@ RSpec.describe Gitlab::Git::Push do
it { is_expected.to be_force_push }
end
context 'when called muiltiple times' do
it 'does not make make multiple calls to the force push check' do
expect(Gitlab::Checks::ForcePush).to receive(:force_push?).once
2.times do
subject.force_push?
end
end
end
end
describe '#branch_added?' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment