Fixed 500 internal server error for MRs with missing source/target in search results
This is to address GitHub issue 7033.
The problem is that when a project has been deleted, merge_request.source_project
or merge_request.target_project
can be nil
, which would cause undefined method 'name_with_namespace' for nil:NilClass
when the aforementioned method is called without checks, as is done in _merge_request.html.haml
.
All I did was check for it inline using a ternary expression, and if a source/target project is nil
, it uses <em>removed project</em>
instead. I'm not a huge fan of returning html from ruby that's within haml (or styling with <em>
instead of CSS); I was going for a small/unobtrusive fix, but would really appreciate suggestions on a cleaner fix.