Guard against nested allows with ref name caching

This avoids the case:

```
allow_ref_name_caching do
  allow_ref_name_caching do
    # using-feature
  end
end
```
This commit is contained in:
Stan Hu 2019-03-27 18:15:26 -05:00
parent db759c5d9c
commit 7a2325e43c
2 changed files with 2 additions and 1 deletions

View File

@ -781,7 +781,7 @@ module Ci
end
def git_ref
strong_memoize(:git_pref) do
strong_memoize(:git_ref) do
if merge_request_event?
##
# In the future, we're going to change this ref to

View File

@ -302,6 +302,7 @@ module Gitlab
# branch, this method allows caching of the ref name directly.
def self.allow_ref_name_caching
return yield unless Gitlab::SafeRequestStore.active?
return yield if ref_name_caching_allowed?
begin
Gitlab::SafeRequestStore[:allow_ref_name_caching] = true