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
Boxiang Sun
gitlab-ce
Commits
6dfede5a
Commit
6dfede5a
authored
6 years ago
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed multiple discussions getting added to diff lines
Closes
https://gitlab.com/gitlab-org/gitlab-ee/issues/8195
parent
1c9b1001
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
3 deletions
+92
-3
app/assets/javascripts/diffs/store/mutations.js
app/assets/javascripts/diffs/store/mutations.js
+9
-3
changelogs/unreleased/multiple-diff-line-discussions-fix.yml
changelogs/unreleased/multiple-diff-line-discussions-fix.yml
+5
-0
spec/javascripts/diffs/store/mutations_spec.js
spec/javascripts/diffs/store/mutations_spec.js
+78
-0
No files found.
app/assets/javascripts/diffs/store/mutations.js
View file @
6dfede5a
...
@@ -130,7 +130,7 @@ export default {
...
@@ -130,7 +130,7 @@ export default {
if
(
file
.
highlighted_diff_lines
)
{
if
(
file
.
highlighted_diff_lines
)
{
file
.
highlighted_diff_lines
=
file
.
highlighted_diff_lines
.
map
(
line
=>
{
file
.
highlighted_diff_lines
=
file
.
highlighted_diff_lines
.
map
(
line
=>
{
if
(
lineCheck
(
line
))
{
if
(
!
line
.
discussions
.
some
(({
id
})
=>
discussion
.
id
===
id
)
&&
lineCheck
(
line
))
{
return
{
return
{
...
line
,
...
line
,
discussions
:
line
.
discussions
.
concat
(
discussion
),
discussions
:
line
.
discussions
.
concat
(
discussion
),
...
@@ -150,11 +150,17 @@ export default {
...
@@ -150,11 +150,17 @@ export default {
return
{
return
{
left
:
{
left
:
{
...
line
.
left
,
...
line
.
left
,
discussions
:
left
?
line
.
left
.
discussions
.
concat
(
discussion
)
:
[],
discussions
:
left
&&
!
line
.
left
.
discussions
.
some
(({
id
})
=>
id
===
discussion
.
id
)
?
line
.
left
.
discussions
.
concat
(
discussion
)
:
(
line
.
left
&&
line
.
left
.
discussions
)
||
[],
},
},
right
:
{
right
:
{
...
line
.
right
,
...
line
.
right
,
discussions
:
right
&&
!
left
?
line
.
right
.
discussions
.
concat
(
discussion
)
:
[],
discussions
:
right
&&
!
left
&&
!
line
.
right
.
discussions
.
some
(({
id
})
=>
id
===
discussion
.
id
)
?
line
.
right
.
discussions
.
concat
(
discussion
)
:
(
line
.
right
&&
line
.
right
.
discussions
)
||
[],
},
},
};
};
}
}
...
...
This diff is collapsed.
Click to expand it.
changelogs/unreleased/multiple-diff-line-discussions-fix.yml
0 → 100644
View file @
6dfede5a
---
title
:
Fixed duplicate discussions getting added to diff lines
merge_request
:
author
:
type
:
fixed
This diff is collapsed.
Click to expand it.
spec/javascripts/diffs/store/mutations_spec.js
View file @
6dfede5a
...
@@ -199,6 +199,84 @@ describe('DiffsStoreMutations', () => {
...
@@ -199,6 +199,84 @@ describe('DiffsStoreMutations', () => {
expect
(
state
.
diffFiles
[
0
].
highlighted_diff_lines
[
0
].
discussions
[
0
].
id
).
toEqual
(
1
);
expect
(
state
.
diffFiles
[
0
].
highlighted_diff_lines
[
0
].
discussions
[
0
].
id
).
toEqual
(
1
);
});
});
it
(
'
should not duplicate discussions on line
'
,
()
=>
{
const
diffPosition
=
{
base_sha
:
'
ed13df29948c41ba367caa757ab3ec4892509910
'
,
head_sha
:
'
b921914f9a834ac47e6fd9420f78db0f83559130
'
,
new_line
:
null
,
new_path
:
'
500-lines-4.txt
'
,
old_line
:
5
,
old_path
:
'
500-lines-4.txt
'
,
start_sha
:
'
ed13df29948c41ba367caa757ab3ec4892509910
'
,
};
const
state
=
{
latestDiff
:
true
,
diffFiles
:
[
{
file_hash
:
'
ABC
'
,
parallel_diff_lines
:
[
{
left
:
{
line_code
:
'
ABC_1
'
,
discussions
:
[],
},
right
:
{
line_code
:
'
ABC_1
'
,
discussions
:
[],
},
},
],
highlighted_diff_lines
:
[
{
line_code
:
'
ABC_1
'
,
discussions
:
[],
},
],
},
],
};
const
discussion
=
{
id
:
1
,
line_code
:
'
ABC_1
'
,
diff_discussion
:
true
,
resolvable
:
true
,
original_position
:
diffPosition
,
position
:
diffPosition
,
diff_file
:
{
file_hash
:
state
.
diffFiles
[
0
].
file_hash
,
},
};
const
diffPositionByLineCode
=
{
ABC_1
:
diffPosition
,
};
mutations
[
types
.
SET_LINE_DISCUSSIONS_FOR_FILE
](
state
,
{
discussion
,
diffPositionByLineCode
,
});
expect
(
state
.
diffFiles
[
0
].
parallel_diff_lines
[
0
].
left
.
discussions
.
length
).
toEqual
(
1
);
expect
(
state
.
diffFiles
[
0
].
parallel_diff_lines
[
0
].
left
.
discussions
[
0
].
id
).
toEqual
(
1
);
expect
(
state
.
diffFiles
[
0
].
parallel_diff_lines
[
0
].
right
.
discussions
).
toEqual
([]);
expect
(
state
.
diffFiles
[
0
].
highlighted_diff_lines
[
0
].
discussions
.
length
).
toEqual
(
1
);
expect
(
state
.
diffFiles
[
0
].
highlighted_diff_lines
[
0
].
discussions
[
0
].
id
).
toEqual
(
1
);
mutations
[
types
.
SET_LINE_DISCUSSIONS_FOR_FILE
](
state
,
{
discussion
,
diffPositionByLineCode
,
});
expect
(
state
.
diffFiles
[
0
].
parallel_diff_lines
[
0
].
left
.
discussions
.
length
).
toEqual
(
1
);
expect
(
state
.
diffFiles
[
0
].
parallel_diff_lines
[
0
].
left
.
discussions
[
0
].
id
).
toEqual
(
1
);
expect
(
state
.
diffFiles
[
0
].
parallel_diff_lines
[
0
].
right
.
discussions
).
toEqual
([]);
expect
(
state
.
diffFiles
[
0
].
highlighted_diff_lines
[
0
].
discussions
.
length
).
toEqual
(
1
);
expect
(
state
.
diffFiles
[
0
].
highlighted_diff_lines
[
0
].
discussions
[
0
].
id
).
toEqual
(
1
);
});
it
(
'
should add legacy discussions to the given line
'
,
()
=>
{
it
(
'
should add legacy discussions to the given line
'
,
()
=>
{
const
diffPosition
=
{
const
diffPosition
=
{
base_sha
:
'
ed13df29948c41ba367caa757ab3ec4892509910
'
,
base_sha
:
'
ed13df29948c41ba367caa757ab3ec4892509910
'
,
...
...
This diff is collapsed.
Click to expand it.
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