BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
375b870b
Commit
375b870b
authored
Mar 17, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '21451-allow-disable-mr-link' into 'master'
Add ability to disable Merge Request URL on push Closes #21451 See merge request !9663
parents
d68c23a0
68e3fa0e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
73 additions
and
1 deletion
+73
-1
projects_controller.rb
app/controllers/projects_controller.rb
+1
-0
get_urls_service.rb
app/services/merge_requests/get_urls_service.rb
+2
-0
_merge_request_merge_settings.html.haml
app/views/projects/_merge_request_merge_settings.html.haml
+4
-0
21451-allow-disable-mr-link.yml
changelogs/unreleased/21451-allow-disable-mr-link.yml
+4
-0
20170301125302_add_printing_merge_request_link_enabled_to_project.rb
...302_add_printing_merge_request_link_enabled_to_project.rb
+18
-0
schema.rb
db/schema.rb
+1
-0
merge_requests_settings_spec.rb
...eatures/projects/settings/merge_requests_settings_spec.rb
+23
-0
internal_spec.rb
spec/requests/api/internal_spec.rb
+10
-1
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 @
375b870b
...
...
@@ -316,6 +316,7 @@ class ProjectsController < Projects::ApplicationController
:namespace_id
,
:only_allow_merge_if_all_discussions_are_resolved
,
:only_allow_merge_if_pipeline_succeeds
,
:printing_merge_request_link_enabled
,
:path
,
:public_builds
,
:request_access_enabled
,
...
...
app/services/merge_requests/get_urls_service.rb
View file @
375b870b
...
...
@@ -7,6 +7,8 @@ module MergeRequests
end
def
execute
(
changes
)
return
[]
unless
project
.
printing_merge_request_link_enabled
branches
=
get_branches
(
changes
)
merge_requests_map
=
opened_merge_requests_from_source_branches
(
branches
)
branches
.
map
do
|
branch
|
...
...
app/views/projects/_merge_request_merge_settings.html.haml
View file @
375b870b
...
...
@@ -13,3 +13,7 @@
=
form
.
label
:only_allow_merge_if_all_discussions_are_resolved
do
=
form
.
check_box
:only_allow_merge_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 @
375b870b
---
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 @
375b870b
# 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 @
375b870b
...
...
@@ -1003,6 +1003,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do
t
.
boolean
"lfs_enabled"
t
.
text
"description_html"
t
.
boolean
"only_allow_merge_if_all_discussions_are_resolved"
t
.
boolean
"printing_merge_request_link_enabled"
,
default:
true
,
null:
false
end
add_index
"projects"
,
[
"ci_id"
],
name:
"index_projects_on_ci_id"
,
using: :btree
...
...
spec/features/projects/settings/merge_requests_settings_spec.rb
View file @
375b870b
...
...
@@ -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'
)
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
spec/requests/api/internal_spec.rb
View file @
375b870b
...
...
@@ -397,16 +397,25 @@ describe API::Internal, api: true do
before
do
project
.
team
<<
[
user
,
:developer
]
get
api
(
"/internal/merge_request_urls?project=
#{
repo_name
}
&changes=
#{
changes
}
"
),
secret_token:
secret_token
end
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
[{
"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"
,
"new_merge_request"
=>
true
}]
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
describe
'POST /notify_post_receive'
do
...
...
spec/services/merge_requests/get_urls_service_spec.rb
View file @
375b870b
...
...
@@ -130,5 +130,15 @@ describe MergeRequests::GetUrlsService do
}])
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
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