Search controller assumes that commit search only happens at project scope
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/controllers/search_controller.rb#L14
def show
search_service = SearchService.new(current_user, params)
@project = search_service.project
@group = search_service.group
return if params[:search].blank?
@search_term = params[:search]
@scope = search_service.scope
@show_snippets = search_service.show_snippets?
@search_results = search_service.search_results
@search_objects = search_service.search_objects
render_commits if @scope == 'commits'
check_single_commit_result
end
The render_commits
and check_single_commit_result
calls both assume that all commits are for @project
In CE, this is obviously correct because we don't have group or global scope indexing. In EE, it's incorrect when elasticsearch is enabled.
Rather than handling this with EE-specific code, I'd rather we modified CE to accept the idea that the commit's project might differ from the search's scope.