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
59577507
Commit
59577507
authored
Dec 30, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add squash option to MR UI
parent
ce33c294
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
61 additions
and
9 deletions
+61
-9
app/assets/stylesheets/pages/merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+1
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+3
-2
app/views/projects/merge_requests/widget/open/_accept.html.haml
...ews/projects/merge_requests/widget/open/_accept.html.haml
+6
-1
app/views/projects/merge_requests/widget/open/_merge_when_build_succeeds.html.haml
...requests/widget/open/_merge_when_build_succeeds.html.haml
+5
-3
app/views/shared/issuable/form/_branch_chooser.html.haml
app/views/shared/issuable/form/_branch_chooser.html.haml
+9
-0
db/migrate/20161230123835_add_squash_to_merge_requests.rb
db/migrate/20161230123835_add_squash_to_merge_requests.rb
+14
-0
db/schema.rb
db/schema.rb
+1
-0
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+21
-2
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
No files found.
app/assets/stylesheets/pages/merge_requests.scss
View file @
59577507
...
...
@@ -62,7 +62,7 @@
}
}
.
remove_source_
checkbox
{
.
merge-param-
checkbox
{
margin
:
0
;
}
}
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
59577507
...
...
@@ -338,7 +338,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
return
end
@merge_request
.
update
(
merge_error:
nil
)
@merge_request
.
update
(
merge_error:
nil
,
squash:
merge_params
[
:squash
]
)
if
params
[
:merge_when_build_succeeds
].
present?
unless
@merge_request
.
head_pipeline
...
...
@@ -699,6 +699,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
approvals_before_merge
approver_group_ids
approver_ids
squash
]
end
...
...
@@ -716,7 +717,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def
merge_params
params
.
permit
(
:should_remove_source_branch
,
:commit_message
)
params
.
permit
(
:should_remove_source_branch
,
:commit_message
,
:squash
)
end
# Make sure merge requests created before 8.0
...
...
app/views/projects/merge_requests/widget/open/_accept.html.haml
View file @
59577507
...
...
@@ -35,9 +35,14 @@
The source branch will be removed.
-
elsif
@merge_request
.
can_remove_source_branch?
(
current_user
)
.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
Remove source branch
.accept-control.checkbox
=
label_tag
:squash
,
class:
'merge-param-checkbox'
do
=
hidden_field_tag
:squash
,
'0'
,
id:
nil
=
check_box_tag
:squash
,
'1'
,
@merge_request
.
squash
Squash commits
.accept-control.right
-
if
@project
.
merge_requests_ff_only_enabled
...
...
app/views/projects/merge_requests/widget/open/_merge_when_build_succeeds.html.haml
View file @
59577507
...
...
@@ -7,10 +7,12 @@
%div
%p
=
succeed
'.'
do
The changes will be
-
if
@merge_request
.
squash
squashed and
-
if
@project
.
merge_requests_ff_only_enabled
The changes will be fast-forward merged into
-
else
The changes will be merged into
fast-forward
merged into
%span
.label-branch
=
@merge_request
.
target_branch
-
if
@merge_request
.
remove_source_branch?
The source branch will be removed.
...
...
app/views/shared/issuable/form/_branch_chooser.html.haml
View file @
59577507
...
...
@@ -28,3 +28,12 @@
=
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.
-
if
issuable
.
new_record?
.form-group
.col-sm-10.col-sm-offset-2
.checkbox
=
label_tag
'merge_request[squash]'
do
=
check_box_tag
'merge_request[squash]'
,
nil
Squash commits on merge. The commit message for the last commit will
be used.
db/migrate/20161230123835_add_squash_to_merge_requests.rb
0 → 100644
View file @
59577507
class
AddSquashToMergeRequests
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
DOWNTIME
=
false
def
up
add_column_with_default
:merge_requests
,
:squash
,
:boolean
,
default:
false
,
allow_null:
false
end
def
down
remove_column
:merge_requests
,
:squash
end
end
db/schema.rb
View file @
59577507
...
...
@@ -782,6 +782,7 @@ ActiveRecord::Schema.define(version: 20170121130655) do
t
.
text
"title_html"
t
.
text
"description_html"
t
.
integer
"time_estimate"
t
.
boolean
"squash"
,
default:
false
,
null:
false
end
add_index
"merge_requests"
,
[
"assignee_id"
],
name:
"index_merge_requests_on_assignee_id"
,
using: :btree
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
59577507
...
...
@@ -492,6 +492,7 @@ describe Projects::MergeRequestsController do
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
id:
merge_request
.
iid
,
squash:
false
,
format:
'raw'
}
end
...
...
@@ -529,8 +530,26 @@ describe Projects::MergeRequestsController do
end
context
'when the sha parameter matches the source SHA'
do
def
merge_with_sha
post
:merge
,
base_params
.
merge
(
sha:
merge_request
.
diff_head_sha
)
def
merge_with_sha
(
params
=
{})
post
:merge
,
base_params
.
merge
(
sha:
merge_request
.
diff_head_sha
).
merge
(
params
)
end
context
'when squash is passed as 1'
do
it
'updates the squash attribute on the MR to true'
do
merge_request
.
update
(
squash:
false
)
merge_with_sha
(
squash:
'1'
)
expect
(
merge_request
.
reload
.
squash
).
to
be_truthy
end
end
context
'when squash is passed as 1'
do
it
'updates the squash attribute on the MR to false'
do
merge_request
.
update
(
squash:
true
)
merge_with_sha
(
squash:
'0'
)
expect
(
merge_request
.
reload
.
squash
).
to
be_falsey
end
end
it
'returns :success'
do
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
59577507
...
...
@@ -154,6 +154,7 @@ MergeRequest:
-
approvals_before_merge
-
rebase_commit_sha
-
time_estimate
-
squash
MergeRequestDiff
:
-
id
-
state
...
...
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