Commit 4d6e377c authored by Sanster's avatar Sanster

fix new MR form erroneously selects tag as source when branch of same name exists #23237

parent 6eeba4b1
......@@ -402,7 +402,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
if params[:ref].present?
@ref = params[:ref]
@commit = @repository.commit(@ref)
@commit = @repository.commit("refs/heads/#{@ref}")
end
render layout: false
......@@ -413,7 +413,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
if params[:ref].present?
@ref = params[:ref]
@commit = @target_project.commit(@ref)
@commit = @target_project.commit("refs/heads/#{@ref}")
end
render layout: false
......
---
title: "Fixes an issue in the new merge request form, where a tag would be selected instead of a branch when they have the same names"
merge_request: 9535
author: Weiqing Chu
......@@ -12,6 +12,33 @@ feature 'Create New Merge Request', feature: true, js: true do
login_as user
end
it 'selects the source branch sha when a tag with the same name exists' do
visit namespace_project_merge_requests_path(project.namespace, project)
click_link 'New Merge Request'
expect(page).to have_content('Source branch')
expect(page).to have_content('Target branch')
first('.js-source-branch').click
first('.dropdown-source-branch .dropdown-content a', text: 'v1.1.0').click
expect(page).to have_content "b83d6e3"
end
it 'selects the target branch sha when a tag with the same name exists' do
visit namespace_project_merge_requests_path(project.namespace, project)
click_link 'New Merge Request'
expect(page).to have_content('Source branch')
expect(page).to have_content('Target branch')
first('.js-target-branch').click
first('.dropdown-target-branch .dropdown-content a', text: 'v1.1.0').click
expect(page).to have_content "b83d6e3"
end
it 'generates a diff for an orphaned branch' do
visit namespace_project_merge_requests_path(project.namespace, project)
......
......@@ -53,6 +53,7 @@ describe "Compare", js: true do
dropdown = find(".js-compare-#{dropdown_type}-dropdown")
dropdown.find(".compare-dropdown-toggle").click
dropdown.fill_in("Filter by Git revision", with: selection)
find_link(selection, visible: true).click
wait_for_ajax
dropdown.find_all("a[data-ref=\"#{selection}\"]", visible: true).last.click
end
end
......@@ -37,7 +37,8 @@ module TestEnv
'conflict-too-large' => '39fa04f',
'deleted-image-test' => '6c17798',
'wip' => 'b9238ee',
'csv' => '3dd0896'
'csv' => '3dd0896',
'v1.1.0' => 'b83d6e3'
}.freeze
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
......
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