Commit 58036d68 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'include-full-path-in-new-mr-page' into 'master'

Include full path of source and target branch names in New Merge Request page

The previous title on the New Merge Request page would only show the group name. which could be confusing. Before, if you attempted to create a new merge request within the repo, it might look like this:

![image](https://gitlab.com/stanhu/gitlab-ce/uploads/d300d3a362406628ffc7c8f2b5cc6b5d/image.png)

Since they are in the same repo, this MR just simplifies this to the branches:

![image](https://gitlab.com/stanhu/gitlab-ce/uploads/5d7b3efc2399b37f84ccfd42bd5d6e8d/image.png)

However, if you create a MR from a forked project, you now see the full namespace:

![image](https://gitlab.com/stanhu/gitlab-ce/uploads/7998c3d19e90d405f4634202cc7181c5/image.png)





Closes #2875

See merge request !1477
parents 26d5eaff 5544d547
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.1.0 (unreleased) v 8.1.0 (unreleased)
- Include full path of source and target branch names in New Merge Request page (Stan Hu)
- Add user preference to view activities as default dashboard (Stan Hu) - Add user preference to view activities as default dashboard (Stan Hu)
- Add option to admin area to sign in as a specific user (Pavel Forkert) - Add option to admin area to sign in as a specific user (Pavel Forkert)
- Show CI status on all pages where commits list is rendered - Show CI status on all pages where commits list is rendered
......
...@@ -71,4 +71,17 @@ module MergeRequestsHelper ...@@ -71,4 +71,17 @@ module MergeRequestsHelper
merge_request.source_branch merge_request.source_branch
end end
end end
def format_mr_branch_names(merge_request)
source_path = merge_request.source_project_path
target_path = merge_request.target_project_path
source_branch = merge_request.source_branch
target_branch = merge_request.target_branch
if source_path == target_path
[source_branch, target_branch]
else
["#{source_path}:#{source_branch}", "#{target_path}:#{target_branch}"]
end
end
end end
%h3.page-title %h3.page-title
New merge request New merge request
%p.slead %p.slead
- source_title, target_title = format_mr_branch_names(@merge_request)
From From
%strong.label-branch #{@merge_request.source_project_namespace}:#{@merge_request.source_branch} %strong.label-branch #{source_title}
%span into %span into
%strong.label-branch #{@merge_request.target_project_namespace}:#{@merge_request.target_branch} %strong.label-branch #{target_title}
%span.pull-right %span.pull-right
= link_to 'Change branches', mr_change_branches_path(@merge_request) = link_to 'Change branches', mr_change_branches_path(@merge_request)
......
require 'spec_helper'
describe MergeRequestsHelper do
describe :issues_sentence do
subject { issues_sentence(issues) }
let(:issues) do
[build(:issue, iid: 1), build(:issue, iid: 2), build(:issue, iid: 3)]
end
it { is_expected.to eq('#1, #2, and #3') }
end
end
require 'spec_helper'
describe MergeRequestsHelper do
describe "#issues_sentence" do
subject { issues_sentence(issues) }
let(:issues) do
[build(:issue, iid: 1), build(:issue, iid: 2), build(:issue, iid: 3)]
end
it { is_expected.to eq('#1, #2, and #3') }
end
describe "#format_mr_branch_names" do
describe "within the same project" do
let(:merge_request) { create(:merge_request) }
subject { format_mr_branch_names(merge_request) }
it { is_expected.to eq([merge_request.source_branch, merge_request.target_branch]) }
end
describe "within different projects" do
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
let(:merge_request) { create(:merge_request, source_project: fork_project, target_project: project) }
subject { format_mr_branch_names(merge_request) }
let(:source_title) { "#{fork_project.path_with_namespace}:#{merge_request.source_branch}" }
let(:target_title) { "#{project.path_with_namespace}:#{merge_request.target_branch}" }
it { is_expected.to eq([source_title, target_title]) }
end
end
end
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