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
Tatuya Kamada
gitlab-ce
Commits
1ca6e99d
Commit
1ca6e99d
authored
Feb 03, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'squash' into 'master'
Backport changes from EE squash See merge request !8912
parents
7dc8b6b2
7550f60d
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
75 additions
and
28 deletions
+75
-28
app/assets/stylesheets/pages/merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+13
-4
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+12
-0
app/models/repository.rb
app/models/repository.rb
+2
-2
app/services/merge_requests/merge_service.rb
app/services/merge_requests/merge_service.rb
+10
-4
app/views/projects/merge_requests/widget/open/_accept.html.haml
...ews/projects/merge_requests/widget/open/_accept.html.haml
+2
-2
app/views/projects/merge_requests/widget/open/_merge_when_build_succeeds.html.haml
...requests/widget/open/_merge_when_build_succeeds.html.haml
+1
-1
app/views/shared/issuable/_form.html.haml
app/views/shared/issuable/_form.html.haml
+2
-0
app/views/shared/issuable/form/_branch_chooser.html.haml
app/views/shared/issuable/form/_branch_chooser.html.haml
+0
-9
app/views/shared/issuable/form/_merge_params.html.haml
app/views/shared/issuable/form/_merge_params.html.haml
+16
-0
spec/lib/gitlab/diff/position_tracer_spec.rb
spec/lib/gitlab/diff/position_tracer_spec.rb
+3
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+11
-3
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+1
-1
spec/support/test_env.rb
spec/support/test_env.rb
+2
-1
No files found.
app/assets/stylesheets/pages/merge_requests.scss
View file @
1ca6e99d
...
@@ -56,15 +56,24 @@
...
@@ -56,15 +56,24 @@
&
.right
{
&
.right
{
float
:
right
;
float
:
right
;
padding-right
:
0
;
padding-right
:
0
;
}
a
{
.modify-merge-commit-link
{
color
:
$gl-text-color
;
color
:
$gl-text-color
;
}
}
}
.
remove_source_
checkbox
{
.
merge-param-
checkbox
{
margin
:
0
;
margin
:
0
;
}
}
a
.fa-question-circle
{
color
:
$gl-text-color-secondary
;
&
:hover
,
&
:focus
{
color
:
$link-hover-color
;
}
}
}
}
}
}
...
...
app/helpers/merge_requests_helper.rb
View file @
1ca6e99d
...
@@ -143,4 +143,16 @@ module MergeRequestsHelper
...
@@ -143,4 +143,16 @@ module MergeRequestsHelper
def
different_base?
(
version1
,
version2
)
def
different_base?
(
version1
,
version2
)
version1
&&
version2
&&
version1
.
base_commit_sha
!=
version2
.
base_commit_sha
version1
&&
version2
&&
version1
.
base_commit_sha
!=
version2
.
base_commit_sha
end
end
def
merge_params
(
merge_request
)
{
merge_when_build_succeeds:
true
,
should_remove_source_branch:
true
,
sha:
merge_request
.
diff_head_sha
}.
merge
(
merge_params_ee
(
merge_request
))
end
def
merge_params_ee
(
merge_request
)
{}
end
end
end
app/models/repository.rb
View file @
1ca6e99d
...
@@ -913,11 +913,11 @@ class Repository
...
@@ -913,11 +913,11 @@ class Repository
end
end
end
end
def
merge
(
user
,
merge_request
,
options
=
{})
def
merge
(
user
,
source
,
merge_request
,
options
=
{})
GitOperationService
.
new
(
user
,
self
).
with_branch
(
GitOperationService
.
new
(
user
,
self
).
with_branch
(
merge_request
.
target_branch
)
do
|
start_commit
|
merge_request
.
target_branch
)
do
|
start_commit
|
our_commit
=
start_commit
.
sha
our_commit
=
start_commit
.
sha
their_commit
=
merge_request
.
diff_head_sha
their_commit
=
source
raise
'Invalid merge target'
unless
our_commit
raise
'Invalid merge target'
unless
our_commit
raise
'Invalid merge source'
unless
their_commit
raise
'Invalid merge source'
unless
their_commit
...
...
app/services/merge_requests/merge_service.rb
View file @
1ca6e99d
...
@@ -6,13 +6,17 @@ module MergeRequests
...
@@ -6,13 +6,17 @@ module MergeRequests
# Executed when you do merge via GitLab UI
# Executed when you do merge via GitLab UI
#
#
class
MergeService
<
MergeRequests
::
BaseService
class
MergeService
<
MergeRequests
::
BaseService
attr_reader
:merge_request
attr_reader
:merge_request
,
:source
def
execute
(
merge_request
)
def
execute
(
merge_request
)
@merge_request
=
merge_request
@merge_request
=
merge_request
return
log_merge_error
(
'Merge request is not mergeable'
,
true
)
unless
@merge_request
.
mergeable?
return
log_merge_error
(
'Merge request is not mergeable'
,
true
)
unless
@merge_request
.
mergeable?
@source
=
find_merge_source
return
log_merge_error
(
'No source for merge'
,
true
)
unless
@source
merge_request
.
in_locked_state
do
merge_request
.
in_locked_state
do
if
commit
if
commit
after_merge
after_merge
...
@@ -34,7 +38,7 @@ module MergeRequests
...
@@ -34,7 +38,7 @@ module MergeRequests
committer:
committer
committer:
committer
}
}
commit_id
=
repository
.
merge
(
current_user
,
merge_request
,
options
)
commit_id
=
repository
.
merge
(
current_user
,
source
,
merge_request
,
options
)
if
commit_id
if
commit_id
merge_request
.
update
(
merge_commit_sha:
commit_id
)
merge_request
.
update
(
merge_commit_sha:
commit_id
)
...
@@ -73,9 +77,11 @@ module MergeRequests
...
@@ -73,9 +77,11 @@ module MergeRequests
end
end
def
merge_request_info
def
merge_request_info
project
=
merge_request
.
project
merge_request
.
to_reference
(
full:
true
)
end
"
#{
project
.
to_reference
}#{
merge_request
.
to_reference
}
"
def
find_merge_source
merge_request
.
diff_head_sha
end
end
end
end
end
end
app/views/projects/merge_requests/widget/open/_accept.html.haml
View file @
1ca6e99d
...
@@ -35,10 +35,10 @@
...
@@ -35,10 +35,10 @@
The source branch will be removed.
The source branch will be removed.
-
elsif
@merge_request
.
can_remove_source_branch?
(
current_user
)
-
elsif
@merge_request
.
can_remove_source_branch?
(
current_user
)
.accept-control.checkbox
.accept-control.checkbox
=
label_tag
:should_remove_source_branch
,
class:
"
remove_source_
checkbox"
do
=
label_tag
:should_remove_source_branch
,
class:
"
merge-param-
checkbox"
do
=
check_box_tag
:should_remove_source_branch
=
check_box_tag
:should_remove_source_branch
Remove source branch
Remove source branch
.accept-control
.right
.accept-control
=
link_to
"#"
,
class:
"modify-merge-commit-link js-toggle-button"
do
=
link_to
"#"
,
class:
"modify-merge-commit-link js-toggle-button"
do
=
icon
(
'edit'
)
=
icon
(
'edit'
)
Modify commit message
Modify commit message
...
...
app/views/projects/merge_requests/widget/open/_merge_when_build_succeeds.html.haml
View file @
1ca6e99d
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
-
if
remove_source_branch_button
||
user_can_cancel_automatic_merge
-
if
remove_source_branch_button
||
user_can_cancel_automatic_merge
.clearfix.prepend-top-10
.clearfix.prepend-top-10
-
if
remove_source_branch_button
-
if
remove_source_branch_button
=
link_to
merge_namespace_project_merge_request_path
(
@merge_request
.
target_project
.
namespace
,
@merge_request
.
target_project
,
@merge_request
,
merge_
when_build_succeeds:
true
,
should_remove_source_branch:
true
,
sha:
@merge_request
.
diff_head_sha
),
remote:
true
,
method: :post
,
class:
"btn btn-grouped btn-primary btn-sm remove_source_branch"
do
=
link_to
merge_namespace_project_merge_request_path
(
@merge_request
.
target_project
.
namespace
,
@merge_request
.
target_project
,
@merge_request
,
merge_
params
(
@merge_request
)
),
remote:
true
,
method: :post
,
class:
"btn btn-grouped btn-primary btn-sm remove_source_branch"
do
=
icon
(
'times'
)
=
icon
(
'times'
)
Remove Source Branch When Merged
Remove Source Branch When Merged
...
...
app/views/shared/issuable/_form.html.haml
View file @
1ca6e99d
...
@@ -43,6 +43,8 @@
...
@@ -43,6 +43,8 @@
=
render
'shared/issuable/form/branch_chooser'
,
issuable:
issuable
,
form:
form
=
render
'shared/issuable/form/branch_chooser'
,
issuable:
issuable
,
form:
form
=
render
'shared/issuable/form/merge_params'
,
issuable:
issuable
-
if
@merge_request_for_resolving_discussions
-
if
@merge_request_for_resolving_discussions
.form-group
.form-group
.col-sm-10.col-sm-offset-2
.col-sm-10.col-sm-offset-2
...
...
app/views/shared/issuable/form/_branch_chooser.html.haml
View file @
1ca6e99d
...
@@ -19,12 +19,3 @@
...
@@ -19,12 +19,3 @@
-
if
issuable
.
new_record?
-
if
issuable
.
new_record?
=
link_to
'Change branches'
,
mr_change_branches_path
(
issuable
)
=
link_to
'Change branches'
,
mr_change_branches_path
(
issuable
)
-
if
issuable
.
can_remove_source_branch?
(
current_user
)
.form-group
.col-sm-10.col-sm-offset-2
.checkbox
=
label_tag
'merge_request[force_remove_source_branch]'
do
=
hidden_field_tag
'merge_request[force_remove_source_branch]'
,
'0'
,
id:
nil
=
check_box_tag
'merge_request[force_remove_source_branch]'
,
'1'
,
issuable
.
force_remove_source_branch?
Remove source branch when merge request is accepted.
app/views/shared/issuable/form/_merge_params.html.haml
0 → 100644
View file @
1ca6e99d
-
issuable
=
local_assigns
.
fetch
(
:issuable
)
-
return
unless
issuable
.
is_a?
(
MergeRequest
)
-
return
if
issuable
.
closed_without_fork?
-# This check is duplicated below, to avoid conflicts with EE.
-
return
unless
issuable
.
can_remove_source_branch?
(
current_user
)
.form-group
.col-sm-10.col-sm-offset-2
-
if
issuable
.
can_remove_source_branch?
(
current_user
)
.checkbox
=
label_tag
'merge_request[force_remove_source_branch]'
do
=
hidden_field_tag
'merge_request[force_remove_source_branch]'
,
'0'
,
id:
nil
=
check_box_tag
'merge_request[force_remove_source_branch]'
,
'1'
,
issuable
.
force_remove_source_branch?
Remove source branch when merge request is accepted.
spec/lib/gitlab/diff/position_tracer_spec.rb
View file @
1ca6e99d
...
@@ -1640,7 +1640,9 @@ describe Gitlab::Diff::PositionTracer, lib: true do
...
@@ -1640,7 +1640,9 @@ describe Gitlab::Diff::PositionTracer, lib: true do
}
}
merge_request
=
create
(
:merge_request
,
source_branch:
second_create_file_commit
.
sha
,
target_branch:
branch_name
,
source_project:
project
)
merge_request
=
create
(
:merge_request
,
source_branch:
second_create_file_commit
.
sha
,
target_branch:
branch_name
,
source_project:
project
)
repository
.
merge
(
current_user
,
merge_request
,
options
)
repository
.
merge
(
current_user
,
merge_request
.
diff_head_sha
,
merge_request
,
options
)
project
.
commit
(
branch_name
)
project
.
commit
(
branch_name
)
end
end
...
...
spec/models/repository_spec.rb
View file @
1ca6e99d
...
@@ -15,7 +15,12 @@ describe Repository, models: true do
...
@@ -15,7 +15,12 @@ describe Repository, models: true do
let
(
:merge_commit
)
do
let
(
:merge_commit
)
do
merge_request
=
create
(
:merge_request
,
source_branch:
'feature'
,
target_branch:
'master'
,
source_project:
project
)
merge_request
=
create
(
:merge_request
,
source_branch:
'feature'
,
target_branch:
'master'
,
source_project:
project
)
merge_commit_id
=
repository
.
merge
(
user
,
merge_request
,
commit_options
)
merge_commit_id
=
repository
.
merge
(
user
,
merge_request
.
diff_head_sha
,
merge_request
,
commit_options
)
repository
.
commit
(
merge_commit_id
)
repository
.
commit
(
merge_commit_id
)
end
end
...
@@ -1082,8 +1087,11 @@ describe Repository, models: true do
...
@@ -1082,8 +1087,11 @@ describe Repository, models: true do
it
'sets the `in_progress_merge_commit_sha` flag for the given merge request'
do
it
'sets the `in_progress_merge_commit_sha` flag for the given merge request'
do
merge_request
=
create
(
:merge_request
,
source_branch:
'feature'
,
target_branch:
'master'
,
source_project:
project
)
merge_request
=
create
(
:merge_request
,
source_branch:
'feature'
,
target_branch:
'master'
,
source_project:
project
)
merge_commit_id
=
repository
.
merge
(
user
,
merge_request
,
commit_options
)
repository
.
commit
(
merge_commit_id
)
merge_commit_id
=
repository
.
merge
(
user
,
merge_request
.
diff_head_sha
,
merge_request
,
commit_options
)
expect
(
merge_request
.
in_progress_merge_commit_sha
).
to
eq
(
merge_commit_id
)
expect
(
merge_request
.
in_progress_merge_commit_sha
).
to
eq
(
merge_commit_id
)
end
end
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
1ca6e99d
...
@@ -89,7 +89,7 @@ describe MergeRequests::RefreshService, services: true do
...
@@ -89,7 +89,7 @@ describe MergeRequests::RefreshService, services: true do
# Merge master -> feature branch
# Merge master -> feature branch
author
=
{
email:
'test@gitlab.com'
,
time:
Time
.
now
,
name:
"Me"
}
author
=
{
email:
'test@gitlab.com'
,
time:
Time
.
now
,
name:
"Me"
}
commit_options
=
{
message:
'Test message'
,
committer:
author
,
author:
author
}
commit_options
=
{
message:
'Test message'
,
committer:
author
,
author:
author
}
@project
.
repository
.
merge
(
@user
,
@merge_request
,
commit_options
)
@project
.
repository
.
merge
(
@user
,
@merge_request
.
diff_head_sha
,
@merge_request
,
commit_options
)
commit
=
@project
.
repository
.
commit
(
'feature'
)
commit
=
@project
.
repository
.
commit
(
'feature'
)
service
.
new
(
@project
,
@user
).
execute
(
@oldrev
,
commit
.
id
,
'refs/heads/feature'
)
service
.
new
(
@project
,
@user
).
execute
(
@oldrev
,
commit
.
id
,
'refs/heads/feature'
)
reload_mrs
reload_mrs
...
...
spec/support/test_env.rb
View file @
1ca6e99d
...
@@ -36,7 +36,8 @@ module TestEnv
...
@@ -36,7 +36,8 @@ module TestEnv
'conflict-non-utf8'
=>
'd0a293c'
,
'conflict-non-utf8'
=>
'd0a293c'
,
'conflict-too-large'
=>
'39fa04f'
,
'conflict-too-large'
=>
'39fa04f'
,
'deleted-image-test'
=>
'6c17798'
,
'deleted-image-test'
=>
'6c17798'
,
'wip'
=>
'b9238ee'
'wip'
=>
'b9238ee'
,
'csv'
=>
'3dd0896'
}
}
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
...
...
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