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
Léo-Paul Géneau
gitlab-ce
Commits
a64bc0c1
Commit
a64bc0c1
authored
Feb 13, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed diff rendering causing a duplicate key warning
Closes
https://gitlab.com/gitlab-org/gitlab-ce/issues/56797
parent
bfdd0247
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
9 deletions
+25
-9
app/assets/javascripts/diffs/store/mutations.js
app/assets/javascripts/diffs/store/mutations.js
+1
-0
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+1
-0
spec/javascripts/diffs/store/utils_spec.js
spec/javascripts/diffs/store/utils_spec.js
+23
-9
No files found.
app/assets/javascripts/diffs/store/mutations.js
View file @
a64bc0c1
...
@@ -144,6 +144,7 @@ export default {
...
@@ -144,6 +144,7 @@ export default {
if
(
left
||
right
)
{
if
(
left
||
right
)
{
return
{
return
{
...
line
,
left
:
line
.
left
?
mapDiscussions
(
line
.
left
)
:
null
,
left
:
line
.
left
?
mapDiscussions
(
line
.
left
)
:
null
,
right
:
line
.
right
?
mapDiscussions
(
line
.
right
,
()
=>
!
left
)
:
null
,
right
:
line
.
right
?
mapDiscussions
(
line
.
right
,
()
=>
!
left
)
:
null
,
};
};
...
...
app/assets/javascripts/diffs/store/utils.js
View file @
a64bc0c1
...
@@ -161,6 +161,7 @@ export function addContextLines(options) {
...
@@ -161,6 +161,7 @@ export function addContextLines(options) {
const
normalizedParallelLines
=
contextLines
.
map
(
line
=>
({
const
normalizedParallelLines
=
contextLines
.
map
(
line
=>
({
left
:
line
,
left
:
line
,
right
:
line
,
right
:
line
,
line_code
:
line
.
line_code
,
}));
}));
if
(
options
.
bottom
)
{
if
(
options
.
bottom
)
{
...
...
spec/javascripts/diffs/store/utils_spec.js
View file @
a64bc0c1
...
@@ -14,7 +14,7 @@ import { MERGE_REQUEST_NOTEABLE_TYPE } from '~/notes/constants';
...
@@ -14,7 +14,7 @@ import { MERGE_REQUEST_NOTEABLE_TYPE } from '~/notes/constants';
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
import
{
noteableDataMock
}
from
'
../../notes/mock_data
'
;
import
{
noteableDataMock
}
from
'
../../notes/mock_data
'
;
const
getDiffFileMock
=
()
=>
Object
.
assign
({},
diffFileMockData
);
const
getDiffFileMock
=
()
=>
JSON
.
parse
(
JSON
.
stringify
(
diffFileMockData
)
);
describe
(
'
DiffsStoreUtils
'
,
()
=>
{
describe
(
'
DiffsStoreUtils
'
,
()
=>
{
describe
(
'
findDiffFile
'
,
()
=>
{
describe
(
'
findDiffFile
'
,
()
=>
{
...
@@ -80,30 +80,44 @@ describe('DiffsStoreUtils', () => {
...
@@ -80,30 +80,44 @@ describe('DiffsStoreUtils', () => {
});
});
describe
(
'
addContextLines
'
,
()
=>
{
describe
(
'
addContextLines
'
,
()
=>
{
it
(
'
should add context lines
properly with bottom parameter
'
,
()
=>
{
it
(
'
should add context lines
'
,
()
=>
{
const
diffFile
=
getDiffFileMock
();
const
diffFile
=
getDiffFileMock
();
const
inlineLines
=
diffFile
.
highlighted_diff_lines
;
const
inlineLines
=
diffFile
.
highlighted_diff_lines
;
const
parallelLines
=
diffFile
.
parallel_diff_lines
;
const
parallelLines
=
diffFile
.
parallel_diff_lines
;
const
lineNumbers
=
{
oldLineNumber
:
3
,
newLineNumber
:
5
};
const
lineNumbers
=
{
oldLineNumber
:
3
,
newLineNumber
:
5
};
const
contextLines
=
[{
lineNumber
:
42
}];
const
contextLines
=
[{
lineNumber
:
42
,
line_code
:
'
123
'
}];
const
options
=
{
inlineLines
,
parallelLines
,
contextLines
,
lineNumbers
,
bottom
:
true
};
const
options
=
{
inlineLines
,
parallelLines
,
contextLines
,
lineNumbers
};
const
inlineIndex
=
utils
.
findIndexInInlineLines
(
inlineLines
,
lineNumbers
);
const
inlineIndex
=
utils
.
findIndexInInlineLines
(
inlineLines
,
lineNumbers
);
const
parallelIndex
=
utils
.
findIndexInParallelLines
(
parallelLines
,
lineNumbers
);
const
parallelIndex
=
utils
.
findIndexInParallelLines
(
parallelLines
,
lineNumbers
);
const
normalizedParallelLine
=
{
const
normalizedParallelLine
=
{
left
:
options
.
contextLines
[
0
],
left
:
options
.
contextLines
[
0
],
right
:
options
.
contextLines
[
0
],
right
:
options
.
contextLines
[
0
],
line_code
:
'
123
'
,
};
};
utils
.
addContextLines
(
options
);
utils
.
addContextLines
(
options
);
expect
(
inlineLines
[
inlineLines
.
length
-
1
]).
toEqual
(
contextLines
[
0
]);
expect
(
inlineLines
[
inlineIndex
]).
toEqual
(
contextLines
[
0
]);
expect
(
parallelLines
[
parallelLines
.
length
-
1
]).
toEqual
(
normalizedParallelLine
);
expect
(
parallelLines
[
parallelIndex
]).
toEqual
(
normalizedParallelLine
);
});
it
(
'
should add context lines properly with bottom parameter
'
,
()
=>
{
const
diffFile
=
getDiffFileMock
();
const
inlineLines
=
diffFile
.
highlighted_diff_lines
;
const
parallelLines
=
diffFile
.
parallel_diff_lines
;
const
lineNumbers
=
{
oldLineNumber
:
3
,
newLineNumber
:
5
};
const
contextLines
=
[{
lineNumber
:
42
,
line_code
:
'
123
'
}];
const
options
=
{
inlineLines
,
parallelLines
,
contextLines
,
lineNumbers
,
bottom
:
true
};
const
normalizedParallelLine
=
{
left
:
options
.
contextLines
[
0
],
right
:
options
.
contextLines
[
0
],
line_code
:
'
123
'
,
};
delete
options
.
bottom
;
utils
.
addContextLines
(
options
);
utils
.
addContextLines
(
options
);
expect
(
inlineLines
[
inline
Index
]).
toEqual
(
contextLines
[
0
]);
expect
(
inlineLines
[
inline
Lines
.
length
-
1
]).
toEqual
(
contextLines
[
0
]);
expect
(
parallelLines
[
parallel
Index
]).
toEqual
(
normalizedParallelLine
);
expect
(
parallelLines
[
parallel
Lines
.
length
-
1
]).
toEqual
(
normalizedParallelLine
);
});
});
});
});
...
...
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