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
Tatuya Kamada
gitlab-ce
Commits
02e87d92
Commit
02e87d92
authored
Sep 08, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize show_diff_size_warning?
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
218219ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+9
-5
app/views/projects/diffs/_diffs.html.haml
app/views/projects/diffs/_diffs.html.haml
+1
-0
app/views/projects/diffs/_warning.html.haml
app/views/projects/diffs/_warning.html.haml
+1
-1
No files found.
app/helpers/diff_helper.rb
View file @
02e87d92
module
DiffHelper
def
safe_diff_files
(
diffs
)
def
allowed_diff_size
if
diff_hard_limit_enabled?
diffs
.
first
(
Commit
::
DIFF_HARD_LIMIT_FILES
)
Commit
::
DIFF_HARD_LIMIT_FILES
else
diffs
.
first
(
Commit
::
DIFF_SAFE_FILES
)
end
.
map
do
|
diff
|
Commit
::
DIFF_SAFE_FILES
end
end
def
safe_diff_files
(
diffs
)
diffs
.
first
(
allowed_diff_size
).
map
do
|
diff
|
Gitlab
::
Diff
::
File
.
new
(
diff
)
end
end
def
show_diff_size_warninig?
(
diffs
)
safe_diff_files
(
diffs
).
size
<
diffs
.
size
diffs
.
size
>
allowed_diff_
size
end
def
diff_hard_limit_enabled?
...
...
app/views/projects/diffs/_diffs.html.haml
View file @
02e87d92
...
...
@@ -11,6 +11,7 @@
-
params_copy
[
:view
]
=
'inline'
=
link_to
"Inline Diff"
,
url_for
(
params_copy
),
{
id:
"commit-diff-viewtype"
}
-
if
show_diff_size_warninig?
(
diffs
)
=
render
'projects/diffs/warning'
,
diffs:
diffs
...
...
app/views/projects/diffs/_warning.html.haml
View file @
02e87d92
...
...
@@ -14,6 +14,6 @@
=
link_to
"Email patch"
,
project_merge_request_path
(
@project
,
@merge_request
,
format: :patch
),
class:
"btn btn-warning btn-small"
%p
To preserve performance only
%strong
#{
safe_diff_files
(
@project
,
diffs
).
size
}
of
#{
diffs
.
size
}
%strong
#{
allowed_diff_
size
}
of
#{
diffs
.
size
}
files displayed.
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