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
58c4a03a
Commit
58c4a03a
authored
May 28, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
ff2d51a7
cc4d5f0a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
7 deletions
+88
-7
changelogs/unreleased/id-bug-suggested-changes-remove-empty-line.yml
...unreleased/id-bug-suggested-changes-remove-empty-line.yml
+5
-0
lib/gitlab/diff/suggestion.rb
lib/gitlab/diff/suggestion.rb
+2
-0
spec/services/suggestions/apply_service_spec.rb
spec/services/suggestions/apply_service_spec.rb
+61
-7
spec/services/suggestions/create_service_spec.rb
spec/services/suggestions/create_service_spec.rb
+20
-0
No files found.
changelogs/unreleased/id-bug-suggested-changes-remove-empty-line.yml
0 → 100644
View file @
58c4a03a
---
title
:
Allow removal of empty lines via suggestions
merge_request
:
28703
author
:
type
:
fixed
lib/gitlab/diff/suggestion.rb
View file @
58c4a03a
...
...
@@ -33,6 +33,8 @@ module Gitlab
end
def
to_content
return
""
if
@text
.
blank?
# The parsed suggestion doesn't have information about the correct
# ending characters (we may have a line break, or not), so we take
# this information from the last line being changed (last
...
...
spec/services/suggestions/apply_service_spec.rb
View file @
58c4a03a
...
...
@@ -5,6 +5,16 @@ require 'spec_helper'
describe
Suggestions
::
ApplyService
do
include
ProjectForksHelper
def
build_position
(
args
=
{})
default_args
=
{
old_path:
"files/ruby/popen.rb"
,
new_path:
"files/ruby/popen.rb"
,
old_line:
nil
,
new_line:
9
,
diff_refs:
merge_request
.
diff_refs
}
Gitlab
::
Diff
::
Position
.
new
(
default_args
.
merge
(
args
))
end
shared_examples
'successfully creates commit and updates suggestion'
do
def
apply
(
suggestion
)
result
=
subject
.
execute
(
suggestion
)
...
...
@@ -43,13 +53,7 @@ describe Suggestions::ApplyService do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
,
:commit_email
)
}
let
(
:position
)
do
Gitlab
::
Diff
::
Position
.
new
(
old_path:
"files/ruby/popen.rb"
,
new_path:
"files/ruby/popen.rb"
,
old_line:
nil
,
new_line:
9
,
diff_refs:
merge_request
.
diff_refs
)
end
let
(
:position
)
{
build_position
}
let
(
:diff_note
)
do
create
(
:diff_note_on_merge_request
,
noteable:
merge_request
,
position:
position
,
project:
project
)
...
...
@@ -333,6 +337,56 @@ describe Suggestions::ApplyService do
it_behaves_like
'successfully creates commit and updates suggestion'
end
context
'remove an empty line suggestion'
do
let
(
:expected_content
)
do
<<~
CONTENT
require 'fileutils'
require 'open3'
module Popen
extend self
def popen(cmd, path=nil)
unless cmd.is_a?(Array)
raise RuntimeError, "System commands must be given as an array of strings"
end
path ||= Dir.pwd
vars = {
"PWD" => path
}
options = {
chdir: path
}
unless File.directory?(path)
FileUtils.mkdir_p(path)
end
@cmd_output = ""
@cmd_status = 0
Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr|
@cmd_output << stdout.read
@cmd_output << stderr.read
@cmd_status = wait_thr.value.exitstatus
end
return @cmd_output, @cmd_status
end
end
CONTENT
end
let
(
:position
)
{
build_position
(
new_line:
13
)
}
let
(
:suggestion
)
do
create
(
:suggestion
,
:content_from_repo
,
note:
diff_note
,
to_content:
""
)
end
it_behaves_like
'successfully creates commit and updates suggestion'
end
end
context
'fork-project'
do
...
...
spec/services/suggestions/create_service_spec.rb
View file @
58c4a03a
...
...
@@ -151,6 +151,26 @@ describe Suggestions::CreateService do
subject
.
execute
end
end
context
'when a patch removes an empty line'
do
let
(
:markdown
)
do
<<-
MARKDOWN
.
strip_heredoc
```suggestion
```
MARKDOWN
end
let
(
:position
)
{
build_position
(
new_line:
13
)
}
it
'creates an appliable suggestion'
do
subject
.
execute
suggestion
=
note
.
suggestions
.
last
expect
(
suggestion
).
to
be_appliable
expect
(
suggestion
.
from_content
).
to
eq
(
"
\n
"
)
expect
(
suggestion
.
to_content
).
to
eq
(
""
)
end
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