Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
610155e0
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,发现更多精彩内容 >>
提交
610155e0
编写于
8月 24, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix-old-mr-diffs' into 'master'
Fix old MR diffs Closes #36516 See merge request !13744
上级
43238a40
e8525e10
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
5 deletion
+70
-5
changelogs/unreleased/fix-old-mr-diffs.yml
changelogs/unreleased/fix-old-mr-diffs.yml
+6
-0
lib/gitlab/diff/file.rb
lib/gitlab/diff/file.rb
+10
-1
spec/lib/gitlab/diff/file_spec.rb
spec/lib/gitlab/diff/file_spec.rb
+54
-4
未找到文件。
changelogs/unreleased/fix-old-mr-diffs.yml
0 → 100644
浏览文件 @
610155e0
---
title
:
Show un-highlighted text diffs when we do not have references to the correct
blobs
merge_request
:
author
:
type
:
fixed
lib/gitlab/diff/file.rb
浏览文件 @
610155e0
...
...
@@ -186,7 +186,10 @@ module Gitlab
end
def
content_changed?
old_blob
&&
new_blob
&&
old_blob
.
id
!=
new_blob
.
id
return
blobs_changed?
if
diff_refs
return
false
if
new_file?
||
deleted_file?
||
renamed_file?
text?
&&
diff_lines
.
any?
end
def
different_type?
...
...
@@ -225,6 +228,10 @@ module Gitlab
private
def
blobs_changed?
old_blob
&&
new_blob
&&
old_blob
.
id
!=
new_blob
.
id
end
def
simple_viewer_class
return
DiffViewer
::
NotDiffable
unless
diffable?
...
...
@@ -250,6 +257,8 @@ module Gitlab
DiffViewer
::
Renamed
elsif
mode_changed?
DiffViewer
::
ModeChanged
else
DiffViewer
::
NoPreview
end
end
...
...
spec/lib/gitlab/diff/file_spec.rb
浏览文件 @
610155e0
...
...
@@ -15,6 +15,17 @@ describe Gitlab::Diff::File do
it
{
expect
(
diff_lines
.
first
).
to
be_kind_of
(
Gitlab
::
Diff
::
Line
)
}
end
describe
'#highlighted_diff_lines'
do
it
'highlights the diff and memoises the result'
do
expect
(
Gitlab
::
Diff
::
Highlight
).
to
receive
(
:new
)
.
with
(
diff_file
,
repository:
project
.
repository
)
.
once
.
and_call_original
diff_file
.
highlighted_diff_lines
end
end
describe
'#mode_changed?'
do
it
{
expect
(
diff_file
.
mode_changed?
).
to
be_falsey
}
end
...
...
@@ -122,8 +133,20 @@ describe Gitlab::Diff::File do
let
(
:commit
)
{
project
.
commit
(
'2f63565e7aac07bcdadb654e253078b727143ec4'
)
}
let
(
:diff_file
)
{
commit
.
diffs
.
diff_file_with_new_path
(
'files/images/6049019_460s.jpg'
)
}
it
'returns true'
do
expect
(
diff_file
.
content_changed?
).
to
be_truthy
context
'when the blobs are different'
do
it
'returns true'
do
expect
(
diff_file
.
content_changed?
).
to
be_truthy
end
end
context
'when there are no diff refs'
do
before
do
allow
(
diff_file
).
to
receive
(
:diff_refs
).
and_return
(
nil
)
end
it
'returns false'
do
expect
(
diff_file
.
content_changed?
).
to
be_falsey
end
end
end
...
...
@@ -131,8 +154,20 @@ describe Gitlab::Diff::File do
let
(
:commit
)
{
project
.
commit
(
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
)
}
let
(
:diff_file
)
{
commit
.
diffs
.
diff_file_with_new_path
(
'files/ruby/popen.rb'
)
}
it
'returns true'
do
expect
(
diff_file
.
content_changed?
).
to
be_truthy
context
'when the blobs are different'
do
it
'returns true'
do
expect
(
diff_file
.
content_changed?
).
to
be_truthy
end
end
context
'when there are no diff refs'
do
before
do
allow
(
diff_file
).
to
receive
(
:diff_refs
).
and_return
(
nil
)
end
it
'returns true'
do
expect
(
diff_file
.
content_changed?
).
to
be_truthy
end
end
end
end
...
...
@@ -270,6 +305,21 @@ describe Gitlab::Diff::File do
expect
(
diff_file
.
simple_viewer
).
to
be_a
(
DiffViewer
::
ModeChanged
)
end
end
context
'when no other conditions apply'
do
before
do
allow
(
diff_file
).
to
receive
(
:content_changed?
).
and_return
(
false
)
allow
(
diff_file
).
to
receive
(
:new_file?
).
and_return
(
false
)
allow
(
diff_file
).
to
receive
(
:deleted_file?
).
and_return
(
false
)
allow
(
diff_file
).
to
receive
(
:renamed_file?
).
and_return
(
false
)
allow
(
diff_file
).
to
receive
(
:mode_changed?
).
and_return
(
false
)
allow
(
diff_file
).
to
receive
(
:raw_text?
).
and_return
(
false
)
end
it
'returns a No Preview viewer'
do
expect
(
diff_file
.
simple_viewer
).
to
be_a
(
DiffViewer
::
NoPreview
)
end
end
end
describe
'#rich_viewer'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录