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
f37f3816
Commit
f37f3816
authored
Jun 09, 2020
by
Thomas Randolph
Committed by
Nicolò Maria Mezzopera
Jun 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a UUID to each Diff File when the raw data is processed
parent
dde42885
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
0 deletions
+42
-0
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+19
-0
spec/frontend/diffs/mock_data/diff_file.js
spec/frontend/diffs/mock_data/diff_file.js
+1
-0
spec/frontend/diffs/store/mutations_spec.js
spec/frontend/diffs/store/mutations_spec.js
+2
-0
spec/frontend/diffs/store/utils_spec.js
spec/frontend/diffs/store/utils_spec.js
+20
-0
No files found.
app/assets/javascripts/diffs/store/utils.js
View file @
f37f3816
...
...
@@ -16,6 +16,7 @@ import {
INLINE_DIFF_VIEW_TYPE
,
PARALLEL_DIFF_VIEW_TYPE
,
}
from
'
../constants
'
;
import
{
uuids
}
from
'
../utils/uuids
'
;
export
function
findDiffFile
(
files
,
match
,
matchKey
=
'
file_hash
'
)
{
return
files
.
find
(
file
=>
file
[
matchKey
]
===
match
);
...
...
@@ -403,8 +404,26 @@ function deduplicateFilesList(files) {
return
Object
.
values
(
dedupedFiles
);
}
function
prepareDiffFile
(
file
)
{
Object
.
assign
(
file
,
{
uuid
:
uuids
({
seeds
:
[
file
.
blob
.
id
,
file
.
diff_refs
.
base_sha
,
file
.
diff_refs
.
start_sha
,
file
.
diff_refs
.
head_sha
,
file
.
file_identifier_hash
,
Number
(
file
.
blob
.
mode
),
],
})[
0
],
});
return
file
;
}
export
function
prepareDiffData
(
diff
,
priorFiles
=
[])
{
const
cleanedFiles
=
(
diff
.
diff_files
||
[])
.
map
(
prepareDiffFile
)
.
map
(
ensureBasicDiffFileLines
)
.
map
(
prepareDiffFileLines
)
.
map
(
finalizeDiffFile
);
...
...
spec/frontend/diffs/mock_data/diff_file.js
View file @
f37f3816
...
...
@@ -13,6 +13,7 @@ export default {
blob_name
:
'
CHANGELOG
'
,
blob_icon
:
'
<i aria-hidden="true" data-hidden="true" class="fa fa-file-text-o fa-fw"></i>
'
,
file_hash
:
'
1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a
'
,
file_identifier_hash
:
'
928f8286952bda02d674b692addcbe077084663a
'
,
file_path
:
'
CHANGELOG
'
,
new_file
:
false
,
deleted_file
:
false
,
...
...
spec/frontend/diffs/store/mutations_spec.js
View file @
f37f3816
...
...
@@ -243,6 +243,8 @@ describe('DiffsStoreMutations', () => {
const
data
=
{
diff_files
:
[
{
blob
:
{},
diff_refs
:
{},
content_sha
:
'
abc
'
,
file_hash
:
fileHash
,
extra_field
:
1
,
...
...
spec/frontend/diffs/store/utils_spec.js
View file @
f37f3816
import
{
clone
}
from
'
lodash
'
;
import
*
as
utils
from
'
~/diffs/store/utils
'
;
import
{
uuids
}
from
'
~/diffs/utils/uuids
'
;
import
{
LINE_POSITION_LEFT
,
LINE_POSITION_RIGHT
,
...
...
@@ -430,6 +431,7 @@ describe('DiffsStoreUtils', () => {
});
describe
(
'
prepareDiffData
'
,
()
=>
{
let
fileId
;
let
mock
;
let
preparedDiff
;
let
splitInlineDiff
;
...
...
@@ -438,6 +440,17 @@ describe('DiffsStoreUtils', () => {
beforeEach
(()
=>
{
mock
=
getDiffFileMock
();
[
fileId
]
=
uuids
({
seeds
:
[
mock
.
blob
.
id
,
mock
.
diff_refs
.
base_sha
,
mock
.
diff_refs
.
start_sha
,
mock
.
diff_refs
.
head_sha
,
mock
.
file_identifier_hash
,
Number
(
mock
.
blob
.
mode
),
],
});
preparedDiff
=
{
diff_files
:
[
mock
]
};
splitInlineDiff
=
{
diff_files
:
[{
...
mock
,
parallel_diff_lines
:
undefined
}],
...
...
@@ -455,6 +468,13 @@ describe('DiffsStoreUtils', () => {
completedDiff
.
diff_files
=
utils
.
prepareDiffData
(
completedDiff
,
[
mock
]);
});
it
(
'
adds a universally unique identifier to each diff file
'
,
()
=>
{
expect
(
preparedDiff
.
diff_files
[
0
].
uuid
).
toBe
(
fileId
);
expect
(
splitInlineDiff
.
diff_files
[
0
].
uuid
).
toBe
(
fileId
);
expect
(
splitParallelDiff
.
diff_files
[
0
].
uuid
).
toBe
(
fileId
);
expect
(
completedDiff
.
diff_files
[
0
].
uuid
).
toBe
(
fileId
);
});
it
(
'
sets the renderIt and collapsed attribute on files
'
,
()
=>
{
const
firstParallelDiffLine
=
preparedDiff
.
diff_files
[
0
].
parallel_diff_lines
[
2
];
...
...
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