Verified Commit eeecb61b authored by Yorick Peterse's avatar Yorick Peterse 🌴

Handle missing merge data for QA issues

Sometimes the "merged by" data for an MR is not available, even when
merged. This can happen when (for some reason) data in the
"merge_request_metrics" table for an MR is not present. How and when
this happens is not clear at this time, but it happened for the
following two MRs:

1. gitlab-ce!27424
2. gitlab-ce!27400

For the first one I fixed the data manually, but I left the second one
as-is.

When this happens, we now fall back to mentioning the assignee (usually
also the person that merges the MR), or the author if both the merger
and assignee were not present.

Fixes #287
parent d7e1092f
...@@ -19,7 +19,9 @@ module ReleaseTools ...@@ -19,7 +19,9 @@ module ReleaseTools
def mention_for_mr def mention_for_mr
if merge_request.labels.include?(COMMUNITY_CONTRIBUTION_LABEL) if merge_request.labels.include?(COMMUNITY_CONTRIBUTION_LABEL)
merge_request.merged_by.username merge_request.merged_by&.username ||
merge_request.assignee&.username ||
merge_request.author.username
else else
merge_request.author.username merge_request.author.username
end end
......
...@@ -42,6 +42,26 @@ describe ReleaseTools::Qa::UsernameExtractor do ...@@ -42,6 +42,26 @@ describe ReleaseTools::Qa::UsernameExtractor do
it 'mentions the merger' do it 'mentions the merger' do
expect(subject.extract_username).to eq(community_merger_tag) expect(subject.extract_username).to eq(community_merger_tag)
end end
it 'mentions the assignee if the merger is not found' do
allow(merge_request)
.to receive(:merged_by)
.and_return(nil)
expect(subject.extract_username).to eq('@DouweM')
end
it 'mentions the author if the merger and assignee could not be found' do
allow(merge_request)
.to receive(:merged_by)
.and_return(nil)
allow(merge_request)
.to receive(:assignee)
.and_return(nil)
expect(subject.extract_username).to eq('@jameslopez')
end
end end
context 'for a regular MR' do context 'for a regular MR' 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