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
5e8aca21
Commit
5e8aca21
authored
Jun 19, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't display comment on unchanged line on both sides in parallel diff
parent
c0c39426
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
24 deletions
+33
-24
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+2
-2
app/models/legacy_diff_note.rb
app/models/legacy_diff_note.rb
+1
-1
lib/gitlab/diff/line.rb
lib/gitlab/diff/line.rb
+10
-10
lib/gitlab/diff/parallel_diff.rb
lib/gitlab/diff/parallel_diff.rb
+10
-10
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+10
-1
No files found.
app/helpers/diff_helper.rb
View file @
5e8aca21
...
@@ -66,12 +66,12 @@ module DiffHelper
...
@@ -66,12 +66,12 @@ module DiffHelper
discussions_left
=
discussions_right
=
nil
discussions_left
=
discussions_right
=
nil
if
left
&&
(
left
.
unchanged?
||
left
.
discussable
?
)
if
left
&&
left
.
discussable?
&&
(
left
.
unchanged?
||
left
.
removed
?
)
line_code
=
diff_file
.
line_code
(
left
)
line_code
=
diff_file
.
line_code
(
left
)
discussions_left
=
@grouped_diff_discussions
[
line_code
]
discussions_left
=
@grouped_diff_discussions
[
line_code
]
end
end
if
right
&
.
discussable
?
if
right
&&
right
.
discussable?
&&
right
.
added
?
line_code
=
diff_file
.
line_code
(
right
)
line_code
=
diff_file
.
line_code
(
right
)
discussions_right
=
@grouped_diff_discussions
[
line_code
]
discussions_right
=
@grouped_diff_discussions
[
line_code
]
end
end
...
...
app/models/legacy_diff_note.rb
View file @
5e8aca21
...
@@ -42,7 +42,7 @@ class LegacyDiffNote < Note
...
@@ -42,7 +42,7 @@ class LegacyDiffNote < Note
end
end
def
for_line?
(
line
)
def
for_line?
(
line
)
!
line
.
meta
?
&&
diff_file
.
line_code
(
line
)
==
self
.
line_code
line
.
discussable
?
&&
diff_file
.
line_code
(
line
)
==
self
.
line_code
end
end
def
original_line_code
def
original_line_code
...
...
lib/gitlab/diff/line.rb
View file @
5e8aca21
...
@@ -42,25 +42,25 @@ module Gitlab
...
@@ -42,25 +42,25 @@ module Gitlab
end
end
def
added?
def
added?
type
==
'new'
||
type
==
'new-nonewline'
%w[new new-nonewline]
.
include?
(
type
)
end
end
def
removed?
def
removed?
type
==
'old'
||
type
==
'old-nonewline'
%w[old old-nonewline]
.
include?
(
type
)
end
def
rich_text
@parent_file
.
highlight_lines!
if
@parent_file
&&
!
@rich_text
@rich_text
end
end
def
meta?
def
meta?
type
==
'match'
%w[match new-nonewline old-nonewline]
.
include?
(
type
)
end
end
def
discussable?
def
discussable?
!
[
'match'
,
'new-nonewline'
,
'old-nonewline'
].
include?
(
type
)
!
meta?
end
def
rich_text
@parent_file
.
highlight_lines!
if
@parent_file
&&
!
@rich_text
@rich_text
end
end
def
as_json
(
opts
=
nil
)
def
as_json
(
opts
=
nil
)
...
...
lib/gitlab/diff/parallel_diff.rb
View file @
5e8aca21
...
@@ -14,16 +14,7 @@ module Gitlab
...
@@ -14,16 +14,7 @@ module Gitlab
lines
=
[]
lines
=
[]
highlighted_diff_lines
=
diff_file
.
highlighted_diff_lines
highlighted_diff_lines
=
diff_file
.
highlighted_diff_lines
highlighted_diff_lines
.
each
do
|
line
|
highlighted_diff_lines
.
each
do
|
line
|
if
line
.
meta?
||
line
.
unchanged?
if
line
.
removed?
# line in the right panel is the same as in the left one
lines
<<
{
left:
line
,
right:
line
}
free_right_index
=
nil
i
+=
1
elsif
line
.
removed?
lines
<<
{
lines
<<
{
left:
line
,
left:
line
,
right:
nil
right:
nil
...
@@ -51,6 +42,15 @@ module Gitlab
...
@@ -51,6 +42,15 @@ module Gitlab
free_right_index
=
nil
free_right_index
=
nil
i
+=
1
i
+=
1
end
end
elsif
line
.
meta?
||
line
.
unchanged?
# line in the right panel is the same as in the left one
lines
<<
{
left:
line
,
right:
line
}
free_right_index
=
nil
i
+=
1
end
end
end
end
...
...
spec/helpers/diff_helper_spec.rb
View file @
5e8aca21
...
@@ -148,12 +148,21 @@ describe DiffHelper do
...
@@ -148,12 +148,21 @@ describe DiffHelper do
it
'puts comments on added lines'
do
it
'puts comments on added lines'
do
left
=
Gitlab
::
Diff
::
Line
.
new
(
'\\nonewline'
,
'old-nonewline'
,
3
,
3
,
3
)
left
=
Gitlab
::
Diff
::
Line
.
new
(
'\\nonewline'
,
'old-nonewline'
,
3
,
3
,
3
)
right
=
Gitlab
::
Diff
::
Line
.
new
(
'new line'
,
'
add
'
,
3
,
3
,
3
)
right
=
Gitlab
::
Diff
::
Line
.
new
(
'new line'
,
'
new
'
,
3
,
3
,
3
)
result
=
helper
.
parallel_diff_discussions
(
left
,
right
,
diff_file
)
result
=
helper
.
parallel_diff_discussions
(
left
,
right
,
diff_file
)
expect
(
result
).
to
eq
([
nil
,
'comment'
])
expect
(
result
).
to
eq
([
nil
,
'comment'
])
end
end
it
'puts comments on unchanged lines'
do
left
=
Gitlab
::
Diff
::
Line
.
new
(
'unchanged line'
,
nil
,
3
,
3
,
3
)
right
=
Gitlab
::
Diff
::
Line
.
new
(
'unchanged line'
,
nil
,
3
,
3
,
3
)
result
=
helper
.
parallel_diff_discussions
(
left
,
right
,
diff_file
)
expect
(
result
).
to
eq
([
'comment'
,
nil
])
end
end
end
describe
"#diff_match_line"
do
describe
"#diff_match_line"
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