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
68e3fa0e
Commit
68e3fa0e
authored
Mar 17, 2017
by
Alex Sanford
Committed by
Sean McGivern
Mar 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to disable Merge Request URL on push
parent
d68c23a0
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
73 additions
and
1 deletion
+73
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-0
app/services/merge_requests/get_urls_service.rb
app/services/merge_requests/get_urls_service.rb
+2
-0
app/views/projects/_merge_request_merge_settings.html.haml
app/views/projects/_merge_request_merge_settings.html.haml
+4
-0
changelogs/unreleased/21451-allow-disable-mr-link.yml
changelogs/unreleased/21451-allow-disable-mr-link.yml
+4
-0
db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb
...302_add_printing_merge_request_link_enabled_to_project.rb
+18
-0
db/schema.rb
db/schema.rb
+1
-0
spec/features/projects/settings/merge_requests_settings_spec.rb
...eatures/projects/settings/merge_requests_settings_spec.rb
+23
-0
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+10
-1
spec/services/merge_requests/get_urls_service_spec.rb
spec/services/merge_requests/get_urls_service_spec.rb
+10
-0
No files found.
app/controllers/projects_controller.rb
View file @
68e3fa0e
...
@@ -316,6 +316,7 @@ class ProjectsController < Projects::ApplicationController
...
@@ -316,6 +316,7 @@ class ProjectsController < Projects::ApplicationController
:namespace_id
,
:namespace_id
,
:only_allow_merge_if_all_discussions_are_resolved
,
:only_allow_merge_if_all_discussions_are_resolved
,
:only_allow_merge_if_pipeline_succeeds
,
:only_allow_merge_if_pipeline_succeeds
,
:printing_merge_request_link_enabled
,
:path
,
:path
,
:public_builds
,
:public_builds
,
:request_access_enabled
,
:request_access_enabled
,
...
...
app/services/merge_requests/get_urls_service.rb
View file @
68e3fa0e
...
@@ -7,6 +7,8 @@ module MergeRequests
...
@@ -7,6 +7,8 @@ module MergeRequests
end
end
def
execute
(
changes
)
def
execute
(
changes
)
return
[]
unless
project
.
printing_merge_request_link_enabled
branches
=
get_branches
(
changes
)
branches
=
get_branches
(
changes
)
merge_requests_map
=
opened_merge_requests_from_source_branches
(
branches
)
merge_requests_map
=
opened_merge_requests_from_source_branches
(
branches
)
branches
.
map
do
|
branch
|
branches
.
map
do
|
branch
|
...
...
app/views/projects/_merge_request_merge_settings.html.haml
View file @
68e3fa0e
...
@@ -13,3 +13,7 @@
...
@@ -13,3 +13,7 @@
=
form
.
label
:only_allow_merge_if_all_discussions_are_resolved
do
=
form
.
label
:only_allow_merge_if_all_discussions_are_resolved
do
=
form
.
check_box
:only_allow_merge_if_all_discussions_are_resolved
=
form
.
check_box
:only_allow_merge_if_all_discussions_are_resolved
%strong
Only allow merge requests to be merged if all discussions are resolved
%strong
Only allow merge requests to be merged if all discussions are resolved
.checkbox
=
form
.
label
:printing_merge_request_link_enabled
do
=
form
.
check_box
:printing_merge_request_link_enabled
%strong
Show link to create/view merge request when pushing from the command line
changelogs/unreleased/21451-allow-disable-mr-link.yml
0 → 100644
View file @
68e3fa0e
---
title
:
Add ability to disable Merge Request URL on push
merge_request
:
9663
author
:
Alex Sanford
db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb
0 → 100644
View file @
68e3fa0e
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddPrintingMergeRequestLinkEnabledToProject
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
def
up
add_column_with_default
(
:projects
,
:printing_merge_request_link_enabled
,
:boolean
,
default:
true
)
end
def
down
remove_column
(
:projects
,
:printing_merge_request_link_enabled
)
end
end
db/schema.rb
View file @
68e3fa0e
...
@@ -1003,6 +1003,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do
...
@@ -1003,6 +1003,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do
t
.
boolean
"lfs_enabled"
t
.
boolean
"lfs_enabled"
t
.
text
"description_html"
t
.
text
"description_html"
t
.
boolean
"only_allow_merge_if_all_discussions_are_resolved"
t
.
boolean
"only_allow_merge_if_all_discussions_are_resolved"
t
.
boolean
"printing_merge_request_link_enabled"
,
default:
true
,
null:
false
end
end
add_index
"projects"
,
[
"ci_id"
],
name:
"index_projects_on_ci_id"
,
using: :btree
add_index
"projects"
,
[
"ci_id"
],
name:
"index_projects_on_ci_id"
,
using: :btree
...
...
spec/features/projects/settings/merge_requests_settings_spec.rb
View file @
68e3fa0e
...
@@ -62,4 +62,27 @@ feature 'Project settings > Merge Requests', feature: true, js: true do
...
@@ -62,4 +62,27 @@ feature 'Project settings > Merge Requests', feature: true, js: true do
expect
(
page
).
to
have_content
(
'Only allow merge requests to be merged if all discussions are resolved'
)
expect
(
page
).
to
have_content
(
'Only allow merge requests to be merged if all discussions are resolved'
)
end
end
end
end
describe
'Checkbox to enable merge request link'
do
before
do
visit
edit_project_path
(
project
)
end
scenario
'is initially checked'
do
checkbox
=
find_field
(
'project_printing_merge_request_link_enabled'
)
expect
(
checkbox
).
to
be_checked
end
scenario
'when unchecked sets :printing_merge_request_link_enabled to false'
do
uncheck
(
'project_printing_merge_request_link_enabled'
)
click_on
(
'Save'
)
# Wait for save to complete and page to reload
checkbox
=
find_field
(
'project_printing_merge_request_link_enabled'
)
expect
(
checkbox
).
not_to
be_checked
project
.
reload
expect
(
project
.
printing_merge_request_link_enabled
).
to
be
(
false
)
end
end
end
end
spec/requests/api/internal_spec.rb
View file @
68e3fa0e
...
@@ -397,16 +397,25 @@ describe API::Internal, api: true do
...
@@ -397,16 +397,25 @@ describe API::Internal, api: true do
before
do
before
do
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
get
api
(
"/internal/merge_request_urls?project=
#{
repo_name
}
&changes=
#{
changes
}
"
),
secret_token:
secret_token
end
end
it
'returns link to create new merge request'
do
it
'returns link to create new merge request'
do
get
api
(
"/internal/merge_request_urls?project=
#{
repo_name
}
&changes=
#{
changes
}
"
),
secret_token:
secret_token
expect
(
json_response
).
to
match
[{
expect
(
json_response
).
to
match
[{
"branch_name"
=>
"new_branch"
,
"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?merge_request%5Bsource_branch%5D=new_branch"
,
"new_merge_request"
=>
true
"new_merge_request"
=>
true
}]
}]
end
end
it
'returns empty array if printing_merge_request_link_enabled is false'
do
project
.
update!
(
printing_merge_request_link_enabled:
false
)
get
api
(
"/internal/merge_request_urls?project=
#{
repo_name
}
&changes=
#{
changes
}
"
),
secret_token:
secret_token
expect
(
json_response
).
to
eq
([])
end
end
end
describe
'POST /notify_post_receive'
do
describe
'POST /notify_post_receive'
do
...
...
spec/services/merge_requests/get_urls_service_spec.rb
View file @
68e3fa0e
...
@@ -130,5 +130,15 @@ describe MergeRequests::GetUrlsService do
...
@@ -130,5 +130,15 @@ describe MergeRequests::GetUrlsService do
}])
}])
end
end
end
end
context
'when printing_merge_request_link_enabled is false'
do
it
'returns empty array'
do
project
.
update!
(
printing_merge_request_link_enabled:
false
)
result
=
service
.
execute
(
existing_branch_changes
)
expect
(
result
).
to
eq
([])
end
end
end
end
end
end
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