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
563c1ca0
Commit
563c1ca0
authored
May 30, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: A diff comment on a change at last line of a file shows as two comments in discussion
parent
52a3d437
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
3 deletions
+33
-3
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+2
-2
app/views/projects/diffs/_line.html.haml
app/views/projects/diffs/_line.html.haml
+1
-1
lib/gitlab/diff/line.rb
lib/gitlab/diff/line.rb
+4
-0
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+26
-0
No files found.
app/helpers/diff_helper.rb
View file @
563c1ca0
...
...
@@ -66,12 +66,12 @@ module DiffHelper
discussions_left
=
discussions_right
=
nil
if
left
&&
(
left
.
unchanged?
||
left
.
removed
?
)
if
left
&&
(
left
.
unchanged?
||
left
.
discussable
?
)
line_code
=
diff_file
.
line_code
(
left
)
discussions_left
=
@grouped_diff_discussions
[
line_code
]
end
if
right
&&
right
.
added
?
if
right
&
.
discussable
?
line_code
=
diff_file
.
line_code
(
right
)
discussions_right
=
@grouped_diff_discussions
[
line_code
]
end
...
...
app/views/projects/diffs/_line.html.haml
View file @
563c1ca0
...
...
@@ -3,7 +3,7 @@
-
discussions
=
local_assigns
.
fetch
(
:discussions
,
nil
)
-
type
=
line
.
type
-
line_code
=
diff_file
.
line_code
(
line
)
-
if
discussions
&&
!
line
.
meta
?
-
if
discussions
&&
line
.
discussable
?
-
line_discussions
=
discussions
[
line_code
]
%tr
.line_holder
{
class:
type
,
id:
(
line_code
unless
plain
)
}
-
case
type
...
...
lib/gitlab/diff/line.rb
View file @
563c1ca0
...
...
@@ -59,6 +59,10 @@ module Gitlab
type
==
'match'
end
def
discussable?
!
[
'match'
,
'new-nonewline'
,
'old-nonewline'
].
include?
(
type
)
end
def
as_json
(
opts
=
nil
)
{
type:
type
,
...
...
spec/helpers/diff_helper_spec.rb
View file @
563c1ca0
...
...
@@ -129,6 +129,32 @@ describe DiffHelper do
end
end
describe
'#parallel_diff_discussions'
do
it
'does not put comments on nonewline lines'
do
discussion
=
{
'abc_3_3'
=>
'comment'
}
helper
.
instance_variable_set
(
:@grouped_diff_discussions
,
discussion
)
diff_file
=
double
(
line_code:
'abc_3_3'
)
left
=
Gitlab
::
Diff
::
Line
.
new
(
'\\nonewline'
,
'old-nonewline'
,
3
,
3
,
3
)
right
=
Gitlab
::
Diff
::
Line
.
new
(
'\\nonewline'
,
'new-nonewline'
,
3
,
3
,
3
)
result
=
helper
.
parallel_diff_discussions
(
left
,
right
,
diff_file
)
expect
(
result
).
to
eq
([
nil
,
nil
])
end
it
'puts comments on added lines'
do
discussion
=
{
'abc_3_3'
=>
'comment'
}
helper
.
instance_variable_set
(
:@grouped_diff_discussions
,
discussion
)
diff_file
=
double
(
line_code:
'abc_3_3'
)
left
=
Gitlab
::
Diff
::
Line
.
new
(
'\\nonewline'
,
'old-nonewline'
,
3
,
3
,
3
)
right
=
Gitlab
::
Diff
::
Line
.
new
(
'new line'
,
'add'
,
3
,
3
,
3
)
result
=
helper
.
parallel_diff_discussions
(
left
,
right
,
diff_file
)
expect
(
result
).
to
eq
([
nil
,
'comment'
])
end
end
describe
"#diff_match_line"
do
let
(
:old_pos
)
{
40
}
let
(
:new_pos
)
{
50
}
...
...
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