Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5e8aca21
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5e8aca21
编写于
6月 19, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't display comment on unchanged line on both sides in parallel diff
上级
c0c39426
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
24 deletion
+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
未找到文件。
app/helpers/diff_helper.rb
浏览文件 @
5e8aca21
...
...
@@ -66,12 +66,12 @@ module DiffHelper
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
)
discussions_left
=
@grouped_diff_discussions
[
line_code
]
end
if
right
&
.
discussable
?
if
right
&&
right
.
discussable?
&&
right
.
added
?
line_code
=
diff_file
.
line_code
(
right
)
discussions_right
=
@grouped_diff_discussions
[
line_code
]
end
...
...
app/models/legacy_diff_note.rb
浏览文件 @
5e8aca21
...
...
@@ -42,7 +42,7 @@ class LegacyDiffNote < Note
end
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
def
original_line_code
...
...
lib/gitlab/diff/line.rb
浏览文件 @
5e8aca21
...
...
@@ -42,25 +42,25 @@ module Gitlab
end
def
added?
type
==
'new'
||
type
==
'new-nonewline'
%w[new new-nonewline]
.
include?
(
type
)
end
def
removed?
type
==
'old'
||
type
==
'old-nonewline'
end
def
rich_text
@parent_file
.
highlight_lines!
if
@parent_file
&&
!
@rich_text
@rich_text
%w[old old-nonewline]
.
include?
(
type
)
end
def
meta?
type
==
'match'
%w[match new-nonewline old-nonewline]
.
include?
(
type
)
end
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
def
as_json
(
opts
=
nil
)
...
...
lib/gitlab/diff/parallel_diff.rb
浏览文件 @
5e8aca21
...
...
@@ -14,16 +14,7 @@ module Gitlab
lines
=
[]
highlighted_diff_lines
=
diff_file
.
highlighted_diff_lines
highlighted_diff_lines
.
each
do
|
line
|
if
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
elsif
line
.
removed?
if
line
.
removed?
lines
<<
{
left:
line
,
right:
nil
...
...
@@ -51,6 +42,15 @@ module Gitlab
free_right_index
=
nil
i
+=
1
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
...
...
spec/helpers/diff_helper_spec.rb
浏览文件 @
5e8aca21
...
...
@@ -148,12 +148,21 @@ describe DiffHelper do
it
'puts comments on added lines'
do
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
)
expect
(
result
).
to
eq
([
nil
,
'comment'
])
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
describe
"#diff_match_line"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录