Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e211ef4e
Commit
e211ef4e
authored
Oct 23, 2018
by
blackst0ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make new merge request URL more friendly when pushing code
parent
4cf1845e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
9 deletions
+15
-9
app/controllers/projects/merge_requests/creations_controller.rb
...ntrollers/projects/merge_requests/creations_controller.rb
+2
-0
app/services/merge_requests/get_urls_service.rb
app/services/merge_requests/get_urls_service.rb
+2
-2
changelogs/unreleased/blackst0ne-update-push-new-merge-request-url.yml
...released/blackst0ne-update-push-new-merge-request-url.yml
+5
-0
config/routes/project.rb
config/routes/project.rb
+1
-2
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+3
-3
spec/services/merge_requests/get_urls_service_spec.rb
spec/services/merge_requests/get_urls_service_spec.rb
+2
-2
No files found.
app/controllers/projects/merge_requests/creations_controller.rb
View file @
e211ef4e
...
...
@@ -89,6 +89,8 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
def
build_merge_request
params
[
:merge_request
]
||=
ActionController
::
Parameters
.
new
(
source_project:
@project
)
params
[
:merge_request
][
:source_branch
]
||=
params
[
:merge_request_source_branch
].
presence
@merge_request
=
::
MergeRequests
::
BuildService
.
new
(
project
,
current_user
,
merge_request_params
.
merge
(
diff_options:
diff_options
)).
execute
end
...
...
app/services/merge_requests/get_urls_service.rb
View file @
e211ef4e
...
...
@@ -50,8 +50,8 @@ module MergeRequests
end
def
url_for_new_merge_request
(
branch_name
)
merge_request_params
=
{
source_branch:
branch_name
}
url
=
Gitlab
::
Routing
.
url_helpers
.
project_new_merge_request_url
(
project
,
merge_request:
merge_request_params
)
url
=
Gitlab
::
Routing
.
url_helpers
.
project_new_merge_request_url
(
project
,
branch_name
)
{
branch_name:
branch_name
,
url:
url
,
new_merge_request:
true
}
end
...
...
changelogs/unreleased/blackst0ne-update-push-new-merge-request-url.yml
0 → 100644
View file @
e211ef4e
---
title
:
Make new merge request URL more friendly when pushing code
merge_request
:
22526
author
:
"
@blackst0ne"
type
:
changed
config/routes/project.rb
View file @
e211ef4e
...
...
@@ -150,8 +150,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post
''
,
action: :create
,
as:
nil
scope
path:
'new'
,
as: :new_merge_request
do
get
''
,
action: :new
scope
constraints:
{
format:
nil
},
action: :new
do
get
:diffs
,
defaults:
{
tab:
'diffs'
}
get
:pipelines
,
defaults:
{
tab:
'pipelines'
}
...
...
@@ -165,6 +163,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get
:diff_for_path
get
:branch_from
get
:branch_to
get
'(:merge_request_source_branch)'
,
action: :new
end
end
...
...
spec/requests/api/internal_spec.rb
View file @
e211ef4e
...
...
@@ -665,7 +665,7 @@ describe API::Internal do
expect
(
json_response
).
to
match
[{
"branch_name"
=>
"new_branch"
,
"url"
=>
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
?merge_request%5Bsource_branch%5D=
new_branch"
,
"url"
=>
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
/
new_branch"
,
"new_merge_request"
=>
true
}]
end
...
...
@@ -686,7 +686,7 @@ describe API::Internal do
expect
(
json_response
).
to
match
[{
"branch_name"
=>
"new_branch"
,
"url"
=>
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
?merge_request%5Bsource_branch%5D=
new_branch"
,
"url"
=>
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
/
new_branch"
,
"new_merge_request"
=>
true
}]
end
...
...
@@ -819,7 +819,7 @@ describe API::Internal do
expect
(
json_response
[
'merge_request_urls'
]).
to
match
[{
"branch_name"
=>
"new_branch"
,
"url"
=>
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
?merge_request%5Bsource_branch%5D=
new_branch"
,
"url"
=>
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
/
new_branch"
,
"new_merge_request"
=>
true
}]
end
...
...
spec/services/merge_requests/get_urls_service_spec.rb
View file @
e211ef4e
...
...
@@ -6,7 +6,7 @@ describe MergeRequests::GetUrlsService do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:service
)
{
described_class
.
new
(
project
)
}
let
(
:source_branch
)
{
"merge-test"
}
let
(
:new_merge_request_url
)
{
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
?merge_request%5Bsource_branch%5D=
#{
source_branch
}
"
}
let
(
:new_merge_request_url
)
{
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
/
#{
source_branch
}
"
}
let
(
:show_merge_request_url
)
{
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/
#{
merge_request
.
iid
}
"
}
let
(
:new_branch_changes
)
{
"
#{
Gitlab
::
Git
::
BLANK_SHA
}
570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/
#{
source_branch
}
"
}
let
(
:deleted_branch_changes
)
{
"d14d6c0abdd253381df51a723d58691b2ee1ab08
#{
Gitlab
::
Git
::
BLANK_SHA
}
refs/heads/
#{
source_branch
}
"
}
...
...
@@ -117,7 +117,7 @@ describe MergeRequests::GetUrlsService do
let
(
:new_branch_changes
)
{
"
#{
Gitlab
::
Git
::
BLANK_SHA
}
570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/new_branch"
}
let
(
:existing_branch_changes
)
{
"d14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/markdown"
}
let
(
:changes
)
{
"
#{
new_branch_changes
}
\n
#{
existing_branch_changes
}
"
}
let
(
:new_merge_request_url
)
{
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
?merge_request%5Bsource_branch%5D=
new_branch"
}
let
(
:new_merge_request_url
)
{
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/
#{
project
.
namespace
.
name
}
/
#{
project
.
path
}
/merge_requests/new
/
new_branch"
}
it
'returns 2 urls for both creating new and showing merge request'
do
result
=
service
.
execute
(
changes
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment