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
c8615ffd
Commit
c8615ffd
authored
Apr 01, 2021
by
Rob Petti
Committed by
Robert Speicher
Apr 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change default squash commit message to MR title
parent
5b18dcdf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
42 deletions
+4
-42
app/models/merge_request.rb
app/models/merge_request.rb
+1
-4
doc/user/project/merge_requests/squash_and_merge.md
doc/user/project/merge_requests/squash_and_merge.md
+1
-4
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+1
-33
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+1
-1
No files found.
app/models/merge_request.rb
View file @
c8615ffd
...
...
@@ -1317,11 +1317,8 @@ class MergeRequest < ApplicationRecord
message
.
join
(
"
\n\n
"
)
end
# Returns the oldest multi-line commit message, or the MR title if none found
def
default_squash_commit_message
strong_memoize
(
:default_squash_commit_message
)
do
first_multiline_commit
&
.
safe_message
||
title
end
title
end
# Returns the oldest multi-line commit
...
...
doc/user/project/merge_requests/squash_and_merge.md
View file @
c8615ffd
...
...
@@ -30,10 +30,7 @@ NOTE:
The squashed commit in this example is followed by a merge commit, because the merge method for this repository uses a merge commit. You can disable merge commits in
**Project Settings > General > Merge requests > Merge method > Fast-forward merge**
.
The squashed commit's commit message is either:
-
Taken from the first multi-line commit message in the merge.
-
The merge request's title if no multi-line commit message is found.
The squashed commit's default commit message is taken from the merge request title.
NOTE:
This only takes effect if there are at least 2 commits. As there is nothing to squash, the commit message does not change if there is only 1 commit.
...
...
spec/models/merge_request_spec.rb
View file @
c8615ffd
...
...
@@ -186,39 +186,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
let
(
:multiline_commits
)
{
subject
.
commits
.
select
(
&
is_multiline
)
}
let
(
:singleline_commits
)
{
subject
.
commits
.
reject
(
&
is_multiline
)
}
context
'when the total number of commits is safe'
do
it
'returns the oldest multiline commit message'
do
expect
(
subject
.
default_squash_commit_message
).
to
eq
(
multiline_commits
.
last
.
message
)
end
end
context
'when the total number of commits is big'
do
let
(
:safe_number
)
{
20
}
before
do
stub_const
(
'MergeRequestDiff::COMMITS_SAFE_SIZE'
,
safe_number
)
end
it
'returns the oldest multiline commit message from safe number of commits'
do
expect
(
subject
.
default_squash_commit_message
).
to
eq
(
"remove emtpy file.(beacase git ignore empty file)
\n
add whitespace test file.
\n
"
)
end
end
it
'returns the merge request title if there are no multiline commits'
do
expect
(
subject
).
to
receive
(
:commits
).
and_return
(
CommitCollection
.
new
(
project
,
singleline_commits
)
)
expect
(
subject
.
default_squash_commit_message
).
to
eq
(
subject
.
title
)
end
it
'does not return commit messages from multiline merge commits'
do
collection
=
CommitCollection
.
new
(
project
,
multiline_commits
).
enrich!
expect
(
collection
.
commits
).
to
all
(
receive
(
:merge_commit?
).
and_return
(
true
)
)
expect
(
subject
).
to
receive
(
:commits
).
and_return
(
collection
)
it
'returns the merge request title'
do
expect
(
subject
.
default_squash_commit_message
).
to
eq
(
subject
.
title
)
end
end
...
...
spec/requests/api/merge_requests_spec.rb
View file @
c8615ffd
...
...
@@ -2533,7 +2533,7 @@ RSpec.describe API::MergeRequests do
it
"results in a default squash commit message when not set"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/merge"
,
user
),
params:
{
squash:
true
}
expect
(
squash_commit
.
message
).
to
eq
(
merge_request
.
default_squash_commit_message
)
expect
(
squash_commit
.
message
.
chomp
).
to
eq
(
merge_request
.
default_squash_commit_message
.
chomp
)
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