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
f727d518
Commit
f727d518
authored
Apr 20, 2021
by
Matthias Käppler
Committed by
Bob Van Landuyt
Apr 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve diff_files endpoint performance
parent
e70d6aa7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
5 deletions
+12
-5
app/assets/javascripts/pages/projects/commit/show/index.js
app/assets/javascripts/pages/projects/commit/show/index.js
+1
-1
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+1
-1
changelogs/unreleased/326316-improve-async-diff-rendering.yml
...gelogs/unreleased/326316-improve-async-diff-rendering.yml
+5
-0
lib/gitlab/diff/highlight.rb
lib/gitlab/diff/highlight.rb
+5
-3
No files found.
app/assets/javascripts/pages/projects/commit/show/index.js
View file @
f727d518
...
...
@@ -33,7 +33,7 @@ if (filesContainer.length) {
axios
.
get
(
batchPath
)
.
then
(({
data
})
=>
{
filesContainer
.
html
(
$
(
data
.
html
));
filesContainer
.
html
(
$
(
data
));
syntaxHighlight
(
filesContainer
);
handleLocationHash
();
new
Diff
();
...
...
app/controllers/projects/commit_controller.rb
View file @
f727d518
...
...
@@ -49,7 +49,7 @@ class Projects::CommitController < Projects::ApplicationController
end
def
diff_files
render
json:
{
html:
view_to_html_string
(
'projects/commit/diff_files'
,
diffs:
@diffs
,
environment:
@environment
)
}
render
template:
'projects/commit/diff_files'
,
layout:
false
,
locals:
{
diffs:
@diffs
,
environment:
@environment
}
end
# rubocop: disable CodeReuse/ActiveRecord
...
...
changelogs/unreleased/326316-improve-async-diff-rendering.yml
0 → 100644
View file @
f727d518
---
title
:
Improve diff_files endpoint performance
merge_request
:
59489
author
:
type
:
performance
lib/gitlab/diff/highlight.rb
View file @
f727d518
...
...
@@ -3,6 +3,8 @@
module
Gitlab
module
Diff
class
Highlight
PREFIX_REGEXP
=
/\A(.)/
.
freeze
attr_reader
:diff_file
,
:diff_lines
,
:repository
,
:project
delegate
:old_path
,
:new_path
,
:old_sha
,
:new_sha
,
to: :diff_file
,
prefix: :diff
...
...
@@ -97,12 +99,12 @@ module Gitlab
rich_line
=
syntax_highlighter
(
diff_line
).
highlight
(
diff_line
.
text
(
prefix:
false
),
context:
{
line_number:
diff_line
.
line
}
)
&
.
html_safe
)
# Only update text if line is found. This will prevent
# issues with submodules given the line only exists in diff content.
if
rich_line
line_prefix
=
diff_line
.
text
=~
/\A(.)/
?
Regexp
.
last_match
(
1
)
:
' '
line_prefix
=
diff_line
.
text
=~
PREFIX_REGEXP
?
Regexp
.
last_match
(
1
)
:
' '
rich_line
.
prepend
(
line_prefix
).
concat
(
"
\n
"
)
end
end
...
...
@@ -131,7 +133,7 @@ module Gitlab
# Only update text if line is found. This will prevent
# issues with submodules given the line only exists in diff content.
if
rich_line
line_prefix
=
diff_line
.
text
=~
/\A(.)/
?
Regexp
.
last_match
(
1
)
:
' '
line_prefix
=
diff_line
.
text
=~
PREFIX_REGEXP
?
Regexp
.
last_match
(
1
)
:
' '
"
#{
line_prefix
}#{
rich_line
}
"
.
html_safe
end
end
...
...
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