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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7f9b7767
Commit
7f9b7767
authored
Jun 27, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace license checks for fast-forward merge (EES)
parent
842aebb9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
34 deletions
+88
-34
app/models/ee/project.rb
app/models/ee/project.rb
+10
-0
app/models/license.rb
app/models/license.rb
+4
-0
app/views/projects/ee/_merge_request_settings.html.haml
app/views/projects/ee/_merge_request_settings.html.haml
+34
-32
changelogs/unreleased-ee/2572-namespace-fast-forward-merge.yml
...elogs/unreleased-ee/2572-namespace-fast-forward-merge.yml
+4
-0
spec/models/ee/merge_request_spec.rb
spec/models/ee/merge_request_spec.rb
+2
-2
spec/models/ee/project_spec.rb
spec/models/ee/project_spec.rb
+34
-0
No files found.
app/models/ee/project.rb
View file @
7f9b7767
...
...
@@ -331,6 +331,16 @@ module EE
super
unless
mirror?
end
def
merge_requests_rebase_enabled
super
&&
feature_available?
(
:merge_request_rebase
)
end
alias_method
:merge_requests_rebase_enabled?
,
:merge_requests_rebase_enabled
def
merge_requests_ff_only_enabled
super
&&
feature_available?
(
:fast_forward_merge
)
end
alias_method
:merge_requests_ff_only_enabled?
,
:merge_requests_ff_only_enabled
private
def
licensed_feature_available?
(
feature
)
...
...
app/models/license.rb
View file @
7f9b7767
...
...
@@ -12,6 +12,7 @@ class License < ActiveRecord::Base
EXPORT_ISSUES_FEATURE
=
'GitLab_ExportIssues'
.
freeze
MERGE_REQUEST_REBASE_FEATURE
=
'GitLab_MergeRequestRebase'
.
freeze
MERGE_REQUEST_SQUASH_FEATURE
=
'GitLab_MergeRequestSquash'
.
freeze
FAST_FORWARD_MERGE_FEATURE
=
'GitLab_FastForwardMerge'
.
freeze
FEATURE_CODES
=
{
geo:
GEO_FEATURE
,
...
...
@@ -21,6 +22,7 @@ class License < ActiveRecord::Base
elastic_search:
ELASTIC_SEARCH_FEATURE
,
related_issues:
RELATED_ISSUES_FEATURE
,
# Features that make sense to Namespace:
fast_forward_merge:
FAST_FORWARD_MERGE_FEATURE
,
deploy_board:
DEPLOY_BOARD_FEATURE
,
file_lock:
FILE_LOCK_FEATURE
,
export_issues:
EXPORT_ISSUES_FEATURE
,
...
...
@@ -36,6 +38,7 @@ class License < ActiveRecord::Base
EES_FEATURES
=
[
{
ELASTIC_SEARCH_FEATURE
=>
1
},
{
RELATED_ISSUES_FEATURE
=>
1
},
{
FAST_FORWARD_MERGE_FEATURE
=>
1
},
{
EXPORT_ISSUES_FEATURE
=>
1
},
{
MERGE_REQUEST_REBASE_FEATURE
=>
1
},
{
MERGE_REQUEST_SQUASH_FEATURE
=>
1
}
...
...
@@ -71,6 +74,7 @@ class License < ActiveRecord::Base
{
AUDITOR_USER_FEATURE
=>
1
},
{
SERVICE_DESK_FEATURE
=>
1
},
{
OBJECT_STORAGE_FEATURE
=>
1
},
{
FAST_FORWARD_MERGE_FEATURE
=>
1
},
{
EXPORT_ISSUES_FEATURE
=>
1
},
{
MERGE_REQUEST_REBASE_FEATURE
=>
1
},
{
MERGE_REQUEST_SQUASH_FEATURE
=>
1
}
...
...
app/views/projects/ee/_merge_request_settings.html.haml
View file @
7f9b7767
-
form
=
local_assigns
.
fetch
(
:form
)
-
project
=
local_assigns
.
fetch
(
:project
)
.form-group
=
label_tag
:merge_method_merge
,
class:
'label-light'
do
Merge method
.radio
=
label_tag
:project_merge_method_merge
do
=
form
.
radio_button
:merge_method
,
:merge
,
class:
"js-merge-method-radio"
%strong
Merge commit
%br
%span
.descr
A merge commit is created for every merge, and merging is allowed as long as there are no conflicts.
.radio
=
label_tag
:project_merge_method_rebase_merge
do
=
form
.
radio_button
:merge_method
,
:rebase_merge
,
class:
"js-merge-method-radio"
%strong
Merge commit with semi-linear history
%br
%span
.descr
A merge commit is created for every merge, but merging is only allowed if fast-forward merge is possible.
This way you could make sure that if this merge request would build, after merging to target branch it would also build.
-
if
project
.
feature_available?
(
:merge_request_rebase
)
-
if
project
.
feature_available?
(
:merge_request_rebase
)
||
project
.
feature_available?
(
:fast_forward_merge
)
.form-group
=
label_tag
:merge_method_merge
,
class:
'label-light'
do
Merge method
.radio
=
label_tag
:project_merge_method_merge
do
=
form
.
radio_button
:merge_method
,
:merge
,
class:
"js-merge-method-radio"
%strong
Merge commit
%br
%span
.descr
When fast-forward merge is not possible, the user is given the option to rebase
.
A merge commit is created for every merge, and merging is allowed as long as there are no conflicts
.
.radio
=
label_tag
:project_merge_method_ff
do
=
form
.
radio_button
:merge_method
,
:ff
,
class:
"js-merge-method-radio"
%strong
Fast-forward merge
%br
%span
.descr
No merge commits are created and all merges are fast-forwarded, which means that merging is only allowed if the branch could be fast-forwarded.
-
if
project
.
feature_available?
(
:merge_request_rebase
)
%br
%span
.descr
When fast-forward merge is not possible, the user is given the option to rebase.
-
if
project
.
feature_available?
(
:merge_request_rebase
)
.radio
=
label_tag
:project_merge_method_rebase_merge
do
=
form
.
radio_button
:merge_method
,
:rebase_merge
,
class:
"js-merge-method-radio"
%strong
Merge commit with semi-linear history
%br
%span
.descr
A merge commit is created for every merge, but merging is only allowed if fast-forward merge is possible.
This way you could make sure that if this merge request would build, after merging to target branch it would also build.
%br
%span
.descr
When fast-forward merge is not possible, the user is given the option to rebase.
-
if
project
.
feature_available?
(
:fast_forward_merge
)
.radio
=
label_tag
:project_merge_method_ff
do
=
form
.
radio_button
:merge_method
,
:ff
,
class:
"js-merge-method-radio"
%strong
Fast-forward merge
%br
%span
.descr
No merge commits are created and all merges are fast-forwarded, which means that merging is only allowed if the branch could be fast-forwarded.
-
if
project
.
feature_available?
(
:merge_request_rebase
)
%br
%span
.descr
When fast-forward merge is not possible, the user is given the option to rebase.
.form-group
=
form
.
label
:merge_requests_template
,
class:
'label-light'
do
...
...
changelogs/unreleased-ee/2572-namespace-fast-forward-merge.yml
0 → 100644
View file @
7f9b7767
---
title
:
Namespace license checks for fast-forward merge (EES)
merge_request
:
2272
author
:
spec/models/ee/merge_request_spec.rb
View file @
7f9b7767
...
...
@@ -16,13 +16,13 @@ describe MergeRequest, models: true do
let
(
:project
)
{
create
(
:project
,
merge_requests_rebase_enabled:
true
)
}
it
'returns false when the project feature is unavailable'
do
expect
(
merge_request
.
target_project
).
to
receive
(
:feature_available?
).
with
(
:merge_request_rebase
).
and_return
(
false
)
expect
(
merge_request
.
target_project
).
to
receive
(
:feature_available?
).
with
(
:merge_request_rebase
).
a
t_least
(
:once
).
a
nd_return
(
false
)
is_expected
.
to
be_falsy
end
it
'returns true when the project feature is available'
do
expect
(
merge_request
.
target_project
).
to
receive
(
:feature_available?
).
with
(
:merge_request_rebase
).
and_return
(
true
)
expect
(
merge_request
.
target_project
).
to
receive
(
:feature_available?
).
with
(
:merge_request_rebase
).
a
t_least
(
:once
).
a
nd_return
(
true
)
is_expected
.
to
be_truthy
end
...
...
spec/models/ee/project_spec.rb
View file @
7f9b7767
...
...
@@ -266,4 +266,38 @@ describe Project, models: true do
expect
(
project
.
service_desk_address
).
to
eq
(
"test+
#{
project
.
full_path
}
@mail.com"
)
end
end
describe
'#merge_method'
do
[
{
ff:
true
,
rebase:
true
,
ff_licensed:
true
,
rebase_licensed:
true
,
method: :ff
},
{
ff:
true
,
rebase:
true
,
ff_licensed:
true
,
rebase_licensed:
false
,
method: :ff
},
{
ff:
true
,
rebase:
true
,
ff_licensed:
false
,
rebase_licensed:
true
,
method: :rebase_merge
},
{
ff:
true
,
rebase:
true
,
ff_licensed:
false
,
rebase_licensed:
false
,
method: :merge
},
{
ff:
true
,
rebase:
false
,
ff_licensed:
true
,
rebase_licensed:
true
,
method: :ff
},
{
ff:
true
,
rebase:
false
,
ff_licensed:
true
,
rebase_licensed:
false
,
method: :ff
},
{
ff:
true
,
rebase:
false
,
ff_licensed:
false
,
rebase_licensed:
true
,
method: :merge
},
{
ff:
true
,
rebase:
false
,
ff_licensed:
false
,
rebase_licensed:
false
,
method: :merge
},
{
ff:
false
,
rebase:
true
,
ff_licensed:
true
,
rebase_licensed:
true
,
method: :rebase_merge
},
{
ff:
false
,
rebase:
true
,
ff_licensed:
true
,
rebase_licensed:
false
,
method: :merge
},
{
ff:
false
,
rebase:
true
,
ff_licensed:
false
,
rebase_licensed:
true
,
method: :rebase_merge
},
{
ff:
false
,
rebase:
true
,
ff_licensed:
false
,
rebase_licensed:
false
,
method: :merge
},
{
ff:
false
,
rebase:
false
,
ff_licensed:
true
,
rebase_licensed:
true
,
method: :merge
},
{
ff:
false
,
rebase:
false
,
ff_licensed:
true
,
rebase_licensed:
false
,
method: :merge
},
{
ff:
false
,
rebase:
false
,
ff_licensed:
false
,
rebase_licensed:
true
,
method: :merge
},
{
ff:
false
,
rebase:
false
,
ff_licensed:
false
,
rebase_licensed:
false
,
method: :merge
}
].
each
do
|
spec
|
context
spec
.
inspect
do
let
(
:project
)
{
build
(
:empty_project
,
merge_requests_rebase_enabled:
spec
[
:rebase
],
merge_requests_ff_only_enabled:
spec
[
:ff
])
}
let
(
:spec
)
{
spec
}
subject
{
project
.
merge_method
}
before
do
stub_licensed_features
(
merge_request_rebase:
spec
[
:rebase_licensed
],
fast_forward_merge:
spec
[
:ff_licensed
])
end
it
{
is_expected
.
to
eq
(
spec
[
:method
])
}
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