Fix 500 error caused by CODEOWNERS with no matches
Including a CODEOWNERS file with lines without any matching username or e-mail regular expressions would cause an Error 500. Don't attempt a database query if there is nothing to query. Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/10282
This commit is contained in:
parent
e17074139e
commit
118d12405a
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix 500 error caused by CODEOWNERS with no matches
|
||||
merge_request: 26072
|
||||
author:
|
||||
type: fixed
|
|
@ -17,7 +17,11 @@ module Gitlab
|
|||
def users
|
||||
return User.none unless @text.present?
|
||||
|
||||
@users ||= User.from_union(union_relations)
|
||||
relations = union_relations
|
||||
|
||||
return User.none unless relations.any?
|
||||
|
||||
@users ||= User.from_union(relations)
|
||||
end
|
||||
|
||||
def usernames
|
||||
|
|
|
@ -48,6 +48,14 @@ describe Gitlab::UserExtractor do
|
|||
it 'includes all mentioned usernames' do
|
||||
expect(extractor.matches[:usernames]).to contain_exactly('user-1', 'user-2', 'user-4')
|
||||
end
|
||||
|
||||
context 'input has no matching e-mail or usernames' do
|
||||
it 'returns an empty list of users' do
|
||||
extractor = described_class.new('My test')
|
||||
|
||||
expect(extractor.users).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#references' do
|
||||
|
|
Loading…
Reference in New Issue