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
7f64a65b
Commit
7f64a65b
authored
Apr 24, 2020
by
jboyson1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Omit line_range from diff position comparison
parent
9cf46c17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+13
-2
spec/frontend/diffs/store/utils_spec.js
spec/frontend/diffs/store/utils_spec.js
+10
-2
No files found.
app/assets/javascripts/diffs/store/utils.js
View file @
7f64a65b
...
...
@@ -437,7 +437,11 @@ export function getDiffPositionByLineCode(diffFiles, useSingleDiffStyle) {
// This method will check whether the discussion is still applicable
// to the diff line in question regarding different versions of the MR
export
function
isDiscussionApplicableToLine
({
discussion
,
diffPosition
,
latestDiff
})
{
const
{
line_code
,
...
diffPositionCopy
}
=
diffPosition
;
const
{
line_code
,
...
dp
}
=
diffPosition
;
// Removing `line_range` from diffPosition because the backend does not
// yet consistently return this property. This check can be removed,
// once this is addressed. see https://gitlab.com/gitlab-org/gitlab/-/issues/213010
const
{
line_range
:
dpNotUsed
,
...
diffPositionCopy
}
=
dp
;
if
(
discussion
.
original_position
&&
discussion
.
position
)
{
const
discussionPositions
=
[
...
...
@@ -446,7 +450,14 @@ export function isDiscussionApplicableToLine({ discussion, diffPosition, latestD
...(
discussion
.
positions
||
[]),
];
return
discussionPositions
.
some
(
position
=>
isEqual
(
position
,
diffPositionCopy
));
const
removeLineRange
=
position
=>
{
const
{
line_range
:
pNotUsed
,
...
positionNoLineRange
}
=
position
;
return
positionNoLineRange
;
};
return
discussionPositions
.
map
(
removeLineRange
)
.
some
(
position
=>
isEqual
(
position
,
diffPositionCopy
));
}
// eslint-disable-next-line
...
...
spec/frontend/diffs/store/utils_spec.js
View file @
7f64a65b
...
...
@@ -503,11 +503,16 @@ describe('DiffsStoreUtils', () => {
},
};
// When multi line comments are fully implemented `line_code` will be
// included in all requests. Until then we need to ensure the logic does
// not change when it is included only in the "comparison" argument.
const
lineRange
=
{
start_line_code
:
'
abc_1_1
'
,
end_line_code
:
'
abc_1_2
'
};
it
(
'
returns true when the discussion is up to date
'
,
()
=>
{
expect
(
utils
.
isDiscussionApplicableToLine
({
discussion
:
discussions
.
upToDateDiscussion1
,
diffPosition
,
diffPosition
:
{
...
diffPosition
,
line_range
:
lineRange
}
,
latestDiff
:
true
,
}),
).
toBe
(
true
);
...
...
@@ -517,7 +522,7 @@ describe('DiffsStoreUtils', () => {
expect
(
utils
.
isDiscussionApplicableToLine
({
discussion
:
discussions
.
outDatedDiscussion1
,
diffPosition
,
diffPosition
:
{
...
diffPosition
,
line_range
:
lineRange
}
,
latestDiff
:
true
,
}),
).
toBe
(
false
);
...
...
@@ -534,6 +539,7 @@ describe('DiffsStoreUtils', () => {
diffPosition
:
{
...
diffPosition
,
lineCode
:
'
ABC_1
'
,
line_range
:
lineRange
,
},
latestDiff
:
true
,
}),
...
...
@@ -551,6 +557,7 @@ describe('DiffsStoreUtils', () => {
diffPosition
:
{
...
diffPosition
,
line_code
:
'
ABC_1
'
,
line_range
:
lineRange
,
},
latestDiff
:
true
,
}),
...
...
@@ -568,6 +575,7 @@ describe('DiffsStoreUtils', () => {
diffPosition
:
{
...
diffPosition
,
lineCode
:
'
ABC_1
'
,
line_range
:
lineRange
,
},
latestDiff
:
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