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
3e86f62f
Commit
3e86f62f
authored
May 27, 2021
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add utility to determine if a file is considered diffable
parent
8f0fce0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
app/assets/javascripts/diffs/utils/diff_file.js
app/assets/javascripts/diffs/utils/diff_file.js
+3
-0
spec/frontend/diffs/utils/diff_file_spec.js
spec/frontend/diffs/utils/diff_file_spec.js
+24
-1
No files found.
app/assets/javascripts/diffs/utils/diff_file.js
View file @
3e86f62f
import
{
diffViewerModes
as
viewerModes
}
from
'
~/ide/constants
'
;
import
{
truncateSha
}
from
'
~/lib/utils/text_utility
'
;
import
{
truncateSha
}
from
'
~/lib/utils/text_utility
'
;
import
{
uuids
}
from
'
~/lib/utils/uuids
'
;
import
{
uuids
}
from
'
~/lib/utils/uuids
'
;
...
@@ -46,6 +47,8 @@ function identifier(file) {
...
@@ -46,6 +47,8 @@ function identifier(file) {
})[
0
];
})[
0
];
}
}
export
const
isNotDiffable
=
(
file
)
=>
file
?.
viewer
?.
name
===
viewerModes
.
not_diffable
;
export
function
prepareRawDiffFile
({
file
,
allFiles
,
meta
=
false
})
{
export
function
prepareRawDiffFile
({
file
,
allFiles
,
meta
=
false
})
{
const
additionalProperties
=
{
const
additionalProperties
=
{
brokenSymlink
:
fileSymlinkInformation
(
file
,
allFiles
),
brokenSymlink
:
fileSymlinkInformation
(
file
,
allFiles
),
...
...
spec/frontend/diffs/utils/diff_file_spec.js
View file @
3e86f62f
import
{
prepareRawDiffFile
,
getShortShaFromFile
}
from
'
~/diffs/utils/diff_file
'
;
import
{
prepareRawDiffFile
,
getShortShaFromFile
,
isNotDiffable
}
from
'
~/diffs/utils/diff_file
'
;
import
{
diffViewerModes
}
from
'
~/ide/constants
'
;
function
getDiffFiles
()
{
function
getDiffFiles
()
{
const
loadFull
=
'
namespace/project/-/merge_requests/12345/diff_for_path?file_identifier=abc
'
;
const
loadFull
=
'
namespace/project/-/merge_requests/12345/diff_for_path?file_identifier=abc
'
;
...
@@ -154,4 +155,26 @@ describe('diff_file utilities', () => {
...
@@ -154,4 +155,26 @@ describe('diff_file utilities', () => {
expect
(
getShortShaFromFile
({
content_sha
:
cs
})).
toBe
(
response
);
expect
(
getShortShaFromFile
({
content_sha
:
cs
})).
toBe
(
response
);
});
});
});
});
describe
(
'
isNotDiffable
'
,
()
=>
{
it
.
each
`
bool | vw
${
true
}
|
${
diffViewerModes
.
not_diffable
}
${
false
}
|
${
diffViewerModes
.
text
}
${
false
}
|
${
diffViewerModes
.
image
}
`
(
'
returns $bool when the viewer is $vw
'
,
({
bool
,
vw
})
=>
{
expect
(
isNotDiffable
({
viewer
:
{
name
:
vw
}
})).
toBe
(
bool
);
});
it
.
each
`
file
${
undefined
}
${
null
}
${{}}
$
{{
viewer
:
undefined
}
}
${{
viewer
:
null
}
}
`
(
'
reports `false` when the file is `$file`
'
,
({
file
})
=>
{
expect
(
isNotDiffable
(
file
)).
toBe
(
false
);
});
});
});
});
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