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
dd8ee395
Commit
dd8ee395
authored
Dec 01, 2021
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error with loading outdated diff lines
Closes
https://gitlab.com/gitlab-org/gitlab/-/issues/346758
parent
439b2200
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
7 deletions
+16
-7
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+1
-1
app/models/note.rb
app/models/note.rb
+9
-0
app/serializers/note_entity.rb
app/serializers/note_entity.rb
+1
-1
app/services/merge_requests/outdated_discussion_diff_lines_service.rb
.../merge_requests/outdated_discussion_diff_lines_service.rb
+5
-5
No files found.
app/controllers/projects/notes_controller.rb
View file @
dd8ee395
...
...
@@ -57,7 +57,7 @@ class Projects::NotesController < Projects::ApplicationController
def
outdated_line_change
diff_lines
=
Rails
.
cache
.
fetch
([
'note'
,
note
.
id
,
'oudated_line_change'
],
expires_in:
7
.
days
)
do
::
MergeRequests
::
OutdatedDiscussionDiffLinesService
.
new
(
project:
@
project
,
note:
note
).
execute
.
to_json
::
MergeRequests
::
OutdatedDiscussionDiffLinesService
.
new
(
project:
note
.
noteable
.
source_
project
,
note:
note
).
execute
.
to_json
end
render
json:
diff_lines
...
...
app/models/note.rb
View file @
dd8ee395
...
...
@@ -603,6 +603,15 @@ class Note < ApplicationRecord
})
end
def
show_outdated_changes?
return
false
unless
for_merge_request?
return
false
unless
Feature
.
enabled?
(
:display_outdated_line_diff
,
noteable
.
source_project
,
default_enabled: :yaml
)
return
false
unless
system
?
return
false
unless
change_position
&
.
line_range
change_position
.
line_range
[
"end"
]
||
change_position
.
line_range
[
"start"
]
end
private
def
system_note_viewable_by?
(
user
)
...
...
app/serializers/note_entity.rb
View file @
dd8ee395
...
...
@@ -51,7 +51,7 @@ class NoteEntity < API::Entities::Note
SystemNoteHelper
.
system_note_icon_name
(
note
)
end
expose
:outdated_line_change_path
,
if:
->
(
note
,
_
)
{
note
.
s
ystem?
&&
note
.
change_position
&
.
line_range
&&
Feature
.
enabled?
(
:display_outdated_line_diff
,
note
.
project
,
default_enabled: :yaml
)
}
do
|
note
|
expose
:outdated_line_change_path
,
if:
->
(
note
,
_
)
{
note
.
s
how_outdated_changes?
}
do
|
note
|
outdated_line_change_namespace_project_note_path
(
namespace_id:
note
.
project
.
namespace
,
project_id:
note
.
project
,
id:
note
)
end
...
...
app/services/merge_requests/outdated_discussion_diff_lines_service.rb
View file @
dd8ee395
...
...
@@ -14,12 +14,12 @@ module MergeRequests
end
def
execute
end_position
=
position
.
line_range
[
"end
"
]
line_position
=
position
.
line_range
[
"end"
]
||
position
.
line_range
[
"start
"
]
diff_line_index
=
diff_lines
.
find_index
do
|
l
|
if
end
_position
[
"new_line"
]
l
.
new_line
==
end
_position
[
"new_line"
]
elsif
end
_position
[
"old_line"
]
l
.
old_line
==
end
_position
[
"old_line"
]
if
line
_position
[
"new_line"
]
l
.
new_line
==
line
_position
[
"new_line"
]
elsif
line
_position
[
"old_line"
]
l
.
old_line
==
line
_position
[
"old_line"
]
end
end
initial_line_index
=
[
diff_line_index
-
OVERFLOW_LINES_COUNT
,
0
].
max
...
...
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