How is GitLab checking if a merge request can be merged without conflicts?

I’ve been trying to figure out how GitLab is checking if a merge request can be merged without conflict and activate the merge button or deactivate it on merge conflict.

I stumbled over Gitaly but couldn’t find the exact spot on where the check is made. Could somebody please introduce the lines of code to me where this happens? I need these lines of code for another project I’m working on.

Thank you for your help!