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
Boxiang Sun
gitlab-ce
Commits
268ec199
Commit
268ec199
authored
May 03, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removes the possibility of commit messages having carriage returns
parent
3ff8d802
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
47 deletions
+46
-47
app/models/repository.rb
app/models/repository.rb
+23
-19
changelogs/unreleased/31671-merge-request-message-contains-carriage-returns.yml
...31671-merge-request-message-contains-carriage-returns.yml
+4
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+0
-21
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+19
-7
No files found.
app/models/repository.rb
View file @
268ec199
...
@@ -791,7 +791,7 @@ class Repository
...
@@ -791,7 +791,7 @@ class Repository
}
}
options
.
merge!
(
get_committer_and_author
(
user
,
email:
author_email
,
name:
author_name
))
options
.
merge!
(
get_committer_and_author
(
user
,
email:
author_email
,
name:
author_name
))
Rugged
::
Commit
.
create
(
rugged
,
options
)
create_commit
(
options
)
end
end
end
end
# rubocop:enable Metrics/ParameterLists
# rubocop:enable Metrics/ParameterLists
...
@@ -838,7 +838,7 @@ class Repository
...
@@ -838,7 +838,7 @@ class Repository
tree:
merge_index
.
write_tree
(
rugged
),
tree:
merge_index
.
write_tree
(
rugged
),
)
)
commit_id
=
Rugged
::
Commit
.
create
(
rugged
,
actual_options
)
commit_id
=
create_commit
(
actual_options
)
merge_request
.
update
(
in_progress_merge_commit_sha:
commit_id
)
merge_request
.
update
(
in_progress_merge_commit_sha:
commit_id
)
commit_id
commit_id
end
end
...
@@ -861,8 +861,7 @@ class Repository
...
@@ -861,8 +861,7 @@ class Repository
committer
=
user_to_committer
(
user
)
committer
=
user_to_committer
(
user
)
Rugged
::
Commit
.
create
(
rugged
,
create_commit
(
message:
commit
.
revert_message
(
user
),
message:
commit
.
revert_message
(
user
),
author:
committer
,
author:
committer
,
committer:
committer
,
committer:
committer
,
tree:
revert_tree_id
,
tree:
revert_tree_id
,
...
@@ -885,8 +884,7 @@ class Repository
...
@@ -885,8 +884,7 @@ class Repository
committer
=
user_to_committer
(
user
)
committer
=
user_to_committer
(
user
)
Rugged
::
Commit
.
create
(
rugged
,
create_commit
(
message:
commit
.
message
,
message:
commit
.
message
,
author:
{
author:
{
email:
commit
.
author_email
,
email:
commit
.
author_email
,
name:
commit
.
author_name
,
name:
commit
.
author_name
,
...
@@ -902,7 +900,7 @@ class Repository
...
@@ -902,7 +900,7 @@ class Repository
GitOperationService
.
new
(
user
,
self
).
with_branch
(
branch_name
)
do
GitOperationService
.
new
(
user
,
self
).
with_branch
(
branch_name
)
do
committer
=
user_to_committer
(
user
)
committer
=
user_to_committer
(
user
)
Rugged
::
Commit
.
create
(
rugged
,
params
.
merge
(
author:
committer
,
committer:
committer
))
create_commit
(
params
.
merge
(
author:
committer
,
committer:
committer
))
end
end
end
end
...
@@ -1146,6 +1144,12 @@ class Repository
...
@@ -1146,6 +1144,12 @@ class Repository
Gitlab
::
Metrics
.
add_event
(
event
,
{
path:
path_with_namespace
}.
merge
(
tags
))
Gitlab
::
Metrics
.
add_event
(
event
,
{
path:
path_with_namespace
}.
merge
(
tags
))
end
end
def
create_commit
(
params
=
{})
params
[
:message
].
delete!
(
"
\r
"
)
Rugged
::
Commit
.
create
(
rugged
,
params
)
end
def
repository_storage_path
def
repository_storage_path
@project
.
repository_storage_path
@project
.
repository_storage_path
end
end
...
...
changelogs/unreleased/31671-merge-request-message-contains-carriage-returns.yml
0 → 100644
View file @
268ec199
---
title
:
Remove carriage returns from commit messages
merge_request
:
11077
author
:
lib/gitlab/git/repository.rb
View file @
268ec199
...
@@ -872,27 +872,6 @@ module Gitlab
...
@@ -872,27 +872,6 @@ module Gitlab
rugged
.
remotes
[
remote_name
].
push
(
refspecs
)
rugged
.
remotes
[
remote_name
].
push
(
refspecs
)
end
end
# Merge the +source_name+ branch into the +target_name+ branch. This is
# equivalent to `git merge --no_ff +source_name+`, since a merge commit
# is always created.
def
merge
(
source_name
,
target_name
,
options
=
{})
our_commit
=
rugged
.
branches
[
target_name
].
target
their_commit
=
rugged
.
branches
[
source_name
].
target
raise
"Invalid merge target"
if
our_commit
.
nil?
raise
"Invalid merge source"
if
their_commit
.
nil?
merge_index
=
rugged
.
merge_commits
(
our_commit
,
their_commit
)
return
false
if
merge_index
.
conflicts?
actual_options
=
options
.
merge
(
parents:
[
our_commit
,
their_commit
],
tree:
merge_index
.
write_tree
(
rugged
),
update_ref:
"refs/heads/
#{
target_name
}
"
)
Rugged
::
Commit
.
create
(
rugged
,
actual_options
)
end
AUTOCRLF_VALUES
=
{
AUTOCRLF_VALUES
=
{
"true"
=>
true
,
"true"
=>
true
,
"false"
=>
false
,
"false"
=>
false
,
...
...
spec/models/repository_spec.rb
View file @
268ec199
...
@@ -1098,21 +1098,33 @@ describe Repository, models: true do
...
@@ -1098,21 +1098,33 @@ describe Repository, models: true do
end
end
describe
'#merge'
do
describe
'#merge'
do
it
'merges the code and return the commit id'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_branch:
'feature'
,
target_branch:
'master'
,
source_project:
project
)
}
let
(
:commit_options
)
do
author
=
repository
.
user_to_committer
(
user
)
{
message:
'Test \r\n\r\n message'
,
committer:
author
,
author:
author
}
end
it
'merges the code and returns the commit id'
do
expect
(
merge_commit
).
to
be_present
expect
(
merge_commit
).
to
be_present
expect
(
repository
.
blob_at
(
merge_commit
.
id
,
'files/ruby/feature.rb'
)).
to
be_present
expect
(
repository
.
blob_at
(
merge_commit
.
id
,
'files/ruby/feature.rb'
)).
to
be_present
end
end
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_commit_id
=
merge
(
repository
,
user
,
merge_request
,
commit_options
)
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
it
'removes carriage returns from commit message'
do
merge_commit_id
=
merge
(
repository
,
user
,
merge_request
,
commit_options
)
expect
(
repository
.
commit
(
merge_commit_id
).
message
).
to
eq
(
commit_options
[
:message
].
delete
(
"
\r
"
))
end
def
merge
(
repository
,
user
,
merge_request
,
options
=
{})
repository
.
merge
(
user
,
merge_request
.
diff_head_sha
,
merge_request
,
options
)
end
end
end
describe
'#revert'
do
describe
'#revert'
do
...
...
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