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
This commit is contained in:
commit
58036d6847
5 changed files with 49 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
|||
Please view this file on the master branch, on stable branches it's out of date.
|
||||
|
||||
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 option to admin area to sign in as a specific user (Pavel Forkert)
|
||||
- Show CI status on all pages where commits list is rendered
|
||||
|
|
|
@ -71,4 +71,17 @@ module MergeRequestsHelper
|
|||
merge_request.source_branch
|
||||
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
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
%h3.page-title
|
||||
New merge request
|
||||
%p.slead
|
||||
- source_title, target_title = format_mr_branch_names(@merge_request)
|
||||
From
|
||||
%strong.label-branch #{@merge_request.source_project_namespace}:#{@merge_request.source_branch}
|
||||
%strong.label-branch #{source_title}
|
||||
%span into
|
||||
%strong.label-branch #{@merge_request.target_project_namespace}:#{@merge_request.target_branch}
|
||||
%strong.label-branch #{target_title}
|
||||
|
||||
%span.pull-right
|
||||
= link_to 'Change branches', mr_change_branches_path(@merge_request)
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
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
|
32
spec/helpers/merge_requests_helper_spec.rb
Normal file
32
spec/helpers/merge_requests_helper_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
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
|
Loading…
Reference in a new issue