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
7c20728a
Commit
7c20728a
authored
Nov 11, 2021
by
Piotr Stankowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove CR newlines when generating merge commit message from template
parent
98ac4e4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
lib/gitlab/merge_requests/merge_commit_message.rb
lib/gitlab/merge_requests/merge_commit_message.rb
+1
-0
spec/lib/gitlab/merge_requests/merge_commit_message_spec.rb
spec/lib/gitlab/merge_requests/merge_commit_message_spec.rb
+33
-0
No files found.
lib/gitlab/merge_requests/merge_commit_message.rb
View file @
7c20728a
...
...
@@ -10,6 +10,7 @@ module Gitlab
return
unless
@merge_request
.
target_project
.
merge_commit_template
.
present?
message
=
@merge_request
.
target_project
.
merge_commit_template
message
=
message
.
delete
(
"
\r
"
)
# Remove placeholders that correspond to empty values and are the last word in the line
# along with all whitespace characters preceding them.
...
...
spec/lib/gitlab/merge_requests/merge_commit_message_spec.rb
View file @
7c20728a
...
...
@@ -183,4 +183,37 @@ RSpec.describe Gitlab::MergeRequests::MergeCommitMessage do
end
end
end
context
'when project has template with CRLF newlines'
do
let
(
:merge_commit_template
)
do
"Merge branch '%{source_branch}' into '%{target_branch}'
\r\n\r\n
%{title}
\r\n\r\n
%{description}
\r\n\r\n
See merge request %{reference}"
end
it
'converts it to LF newlines'
do
expect
(
subject
.
message
).
to
eq
<<~
MSG
.
rstrip
Merge branch 'feature' into 'master'
Bugfix
Merge Request Description
Next line
See merge request
#{
merge_request
.
to_reference
(
full:
true
)
}
MSG
end
context
'when description is empty string'
do
let
(
:merge_request_description
)
{
''
}
it
'skips description placeholder and removes new line characters before it'
do
expect
(
subject
.
message
).
to
eq
<<~
MSG
.
rstrip
Merge branch 'feature' into 'master'
Bugfix
See merge request
#{
merge_request
.
to_reference
(
full:
true
)
}
MSG
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