Don't load labels in /merge_requests/new unless @merge_request.can_be_created == true

We currently load labels (@labels = LabelsFinder.new(current_user, project_id: @project.id).execute) in Projects::MergeRequests::CreationsController#new even if @merge_request.can_be_created == false, which means that we render the new_compare partial and we don't use @labels here.

Also, in https://gitlab.com/gitlab-org/gitlab-ce/blob/3b2d68d37d39047e25fbe0ae51cafa39f22805f8/app/views/shared/issuable/form/_metadata.html.haml#L6, we're checking for labels twice:

  1. https://gitlab.com/gitlab-org/gitlab-ce/blob/3b2d68d37d39047e25fbe0ae51cafa39f22805f8/app/views/shared/issuable/form/_metadata.html.haml#L6
  2. https://gitlab.com/gitlab-org/gitlab-ce/blob/3b2d68d37d39047e25fbe0ae51cafa39f22805f8/app/views/shared/issuable/form/_metadata.html.haml#L23
Edited Jun 17, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading