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
c7c63b2f
Commit
c7c63b2f
authored
Jan 08, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
eea44697
22ab2d04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
13 deletions
+118
-13
changelogs/unreleased/osw-fix-bottom-expansion-diff-comment.yml
...logs/unreleased/osw-fix-bottom-expansion-diff-comment.yml
+5
-0
lib/gitlab/diff/lines_unfolder.rb
lib/gitlab/diff/lines_unfolder.rb
+8
-3
spec/lib/gitlab/diff/lines_unfolder_spec.rb
spec/lib/gitlab/diff/lines_unfolder_spec.rb
+105
-10
No files found.
changelogs/unreleased/osw-fix-bottom-expansion-diff-comment.yml
0 → 100644
View file @
c7c63b2f
---
title
:
Adjusts duplicated line when commenting on unfolded diff lines (in the bottom)
merge_request
:
24201
author
:
type
:
fixed
lib/gitlab/diff/lines_unfolder.rb
View file @
c7c63b2f
...
...
@@ -158,9 +158,14 @@ module Gitlab
from
=
comment_position
-
UNFOLD_CONTEXT_SIZE
# There's no line before the match if it's in the top-most
# position.
prev_line_number
=
line_before_unfold_position
&
.
old_pos
||
0
prev_line_number
=
if
bottom?
last_line
.
old_pos
else
# There's no line before the match if it's in the top-most
# position.
line_before_unfold_position
&
.
old_pos
||
0
end
if
from
<=
prev_line_number
+
1
@generate_top_match_line
=
false
...
...
spec/lib/gitlab/diff/lines_unfolder_spec.rb
View file @
c7c63b2f
...
...
@@ -301,8 +301,7 @@ describe Gitlab::Diff::LinesUnfolder do
expected_diff_lines
.
each_with_index
do
|
expected_line
,
i
|
line
=
new_diff_lines
[
i
]
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
])
.
to
eq
([
expected_line
[
0
],
expected_line
[
1
],
expected_line
[
2
]])
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
]).
to
eq
(
expected_line
)
end
end
...
...
@@ -403,8 +402,7 @@ describe Gitlab::Diff::LinesUnfolder do
expected_diff_lines
.
each_with_index
do
|
expected_line
,
i
|
line
=
new_diff_lines
[
i
]
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
])
.
to
eq
([
expected_line
[
0
],
expected_line
[
1
],
expected_line
[
2
]])
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
]).
to
eq
(
expected_line
)
end
end
...
...
@@ -505,8 +503,7 @@ describe Gitlab::Diff::LinesUnfolder do
expected_diff_lines
.
each_with_index
do
|
expected_line
,
i
|
line
=
new_diff_lines
[
i
]
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
])
.
to
eq
([
expected_line
[
0
],
expected_line
[
1
],
expected_line
[
2
]])
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
]).
to
eq
(
expected_line
)
end
end
...
...
@@ -604,8 +601,7 @@ describe Gitlab::Diff::LinesUnfolder do
expected_diff_lines
.
each_with_index
do
|
expected_line
,
i
|
line
=
new_diff_lines
[
i
]
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
])
.
to
eq
([
expected_line
[
0
],
expected_line
[
1
],
expected_line
[
2
]])
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
]).
to
eq
(
expected_line
)
end
end
...
...
@@ -729,8 +725,7 @@ describe Gitlab::Diff::LinesUnfolder do
expected_diff_lines
.
each_with_index
do
|
expected_line
,
i
|
line
=
new_diff_lines
[
i
]
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
])
.
to
eq
([
expected_line
[
0
],
expected_line
[
1
],
expected_line
[
2
]])
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
]).
to
eq
(
expected_line
)
end
end
...
...
@@ -746,5 +741,105 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
end
context
'position requires bottom expansion and no new match line'
do
let
(
:position
)
do
Gitlab
::
Diff
::
Position
.
new
(
base_sha:
"1c59dfa64afbea8c721bb09a06a9d326c952ea19"
,
start_sha:
"1c59dfa64afbea8c721bb09a06a9d326c952ea19"
,
head_sha:
"1487062132228de836236c522fe52fed4980a46c"
,
old_path:
"build-aux/flatpak/org.gnome.Nautilus.json"
,
new_path:
"build-aux/flatpak/org.gnome.Nautilus.json"
,
position_type:
"text"
,
old_line:
95
,
new_line:
87
)
end
context
'blob lines'
do
let
(
:expected_blob_lines
)
do
[[
94
,
94
,
"
\"
url
\"
:
\"
https://gitlab.gnome.org/GNOME/nautilus.git
\"
"
],
[
95
,
95
,
" }"
],
[
96
,
96
,
" ]"
],
[
97
,
97
,
" }"
],
[
98
,
98
,
" ]"
]]
end
it
'returns the extracted blob lines correctly'
do
extracted_lines
=
subject
.
blob_lines
expect
(
extracted_lines
.
size
).
to
eq
(
5
)
extracted_lines
.
each_with_index
do
|
line
,
i
|
expect
([
line
.
old_line
,
line
.
new_line
,
line
.
text
]).
to
eq
(
expected_blob_lines
[
i
])
end
end
end
context
'diff lines'
do
let
(
:expected_diff_lines
)
do
[[
7
,
7
,
"@@ -7,9 +7,6 @@"
],
[
7
,
7
,
"
\"
tags
\"
: [
\"
devel
\"
,
\"
development
\"
,
\"
nightly
\"
],"
],
[
8
,
8
,
"
\"
desktop-file-name-prefix
\"
:
\"
(Development)
\"
,"
],
[
9
,
9
,
"
\"
finish-args
\"
: ["
],
[
10
,
10
,
"-
\"
--share=ipc
\"
,
\"
--socket=x11
\"
,"
],
[
11
,
10
,
"-
\"
--socket=wayland
\"
,"
],
[
12
,
10
,
"-
\"
--talk-name=org.gnome.OnlineAccounts
\"
,"
],
[
13
,
10
,
"
\"
--talk-name=org.freedesktop.Tracker1
\"
,"
],
[
14
,
11
,
"
\"
--filesystem=home
\"
,"
],
[
15
,
12
,
"
\"
--talk-name=org.gtk.vfs
\"
,
\"
--talk-name=org.gtk.vfs.*
\"
,"
],
[
62
,
59
,
"@@ -62,7 +59,7 @@"
],
[
62
,
59
,
" },"
],
[
63
,
60
,
" {"
],
[
64
,
61
,
"
\"
name
\"
:
\"
gnome-desktop
\"
,"
],
[
65
,
62
,
"-
\"
config-opts
\"
: [
\"
--disable-debug-tools
\"
,
\"
--disable-udev
\"
],"
],
[
66
,
62
,
"+
\"
config-opts
\"
: [
\"
--disable-debug-tools
\"
,
\"
--disable-
\"
],"
],
[
66
,
63
,
"
\"
sources
\"
: ["
],
[
67
,
64
,
" {"
],
[
68
,
65
,
"
\"
type
\"
:
\"
git
\"
,"
],
[
83
,
80
,
"@@ -83,11 +80,6 @@"
],
[
83
,
80
,
"
\"
buildsystem
\"
:
\"
meson
\"
,"
],
[
84
,
81
,
"
\"
builddir
\"
: true,"
],
[
85
,
82
,
"
\"
name
\"
:
\"
nautilus
\"
,"
],
[
86
,
83
,
"-
\"
config-opts
\"
: ["
],
[
87
,
83
,
"-
\"
-Denable-desktop=false
\"
,"
],
[
88
,
83
,
"-
\"
-Denable-selinux=false
\"
,"
],
[
89
,
83
,
"-
\"
--libdir=/app/lib
\"
"
],
[
90
,
83
,
"- ],"
],
[
91
,
83
,
"
\"
sources
\"
: ["
],
[
92
,
84
,
" {"
],
[
93
,
85
,
"
\"
type
\"
:
\"
git
\"
,"
],
# No new match line
# Injected blob lines
[
94
,
86
,
"
\"
url
\"
:
\"
https://gitlab.gnome.org/GNOME/nautilus.git
\"
"
],
[
95
,
87
,
" }"
],
[
96
,
88
,
" ]"
],
[
97
,
89
,
" }"
],
[
98
,
90
,
" ]"
]]
# end
end
it
'return merge of blob lines with diff lines correctly'
do
new_diff_lines
=
subject
.
unfolded_diff_lines
expected_diff_lines
.
each_with_index
do
|
expected_line
,
i
|
line
=
new_diff_lines
[
i
]
expect
([
line
.
old_pos
,
line
.
new_pos
,
line
.
text
]).
to
eq
(
expected_line
)
end
end
it
'merged lines have correct line codes'
do
new_diff_lines
=
subject
.
unfolded_diff_lines
new_diff_lines
.
each_with_index
do
|
line
,
i
|
old_pos
,
new_pos
=
expected_diff_lines
[
i
][
0
],
expected_diff_lines
[
i
][
1
]
unless
line
.
type
==
'match'
expect
(
line
.
line_code
).
to
eq
(
Gitlab
::
Git
.
diff_line_code
(
diff_file
.
file_path
,
new_pos
,
old_pos
))
end
end
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