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
iv
gitlab-ce
Commits
2e9f03e5
Commit
2e9f03e5
authored
Apr 19, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define constants only if not defined yet and freeze them
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
53a1d705
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
app/models/commit.rb
app/models/commit.rb
+3
-3
lib/file_size_validator.rb
lib/file_size_validator.rb
+4
-4
No files found.
app/models/commit.rb
View file @
2e9f03e5
...
...
@@ -12,11 +12,11 @@ class Commit
attr_accessor
:project
DIFF_SAFE_LINES
=
Gitlab
::
Git
::
DiffCollection
::
DEFAULT_LIMITS
[
:max_lines
]
DIFF_SAFE_LINES
||
=
Gitlab
::
Git
::
DiffCollection
::
DEFAULT_LIMITS
[
:max_lines
]
# Commits above this size will not be rendered in HTML
DIFF_HARD_LIMIT_FILES
=
1000
unless
defined?
(
DIFF_HARD_LIMIT_FILES
)
DIFF_HARD_LIMIT_LINES
=
50000
unless
defined?
(
DIFF_HARD_LIMIT_LINES
)
DIFF_HARD_LIMIT_FILES
||=
1000
DIFF_HARD_LIMIT_LINES
||=
50000
class
<<
self
def
decorate
(
commits
,
project
)
...
...
lib/file_size_validator.rb
View file @
2e9f03e5
class
FileSizeValidator
<
ActiveModel
::
EachValidator
MESSAGES
=
{
is: :wrong_size
,
minimum: :size_too_small
,
maximum: :size_too_big
}.
freeze
CHECKS
=
{
is: :==
,
minimum:
:
>=
,
maximum: :<=
}.
freeze
MESSAGES
||
=
{
is: :wrong_size
,
minimum: :size_too_small
,
maximum: :size_too_big
}.
freeze
CHECKS
||
=
{
is: :==
,
minimum:
:
>=
,
maximum: :<=
}.
freeze
DEFAULT_TOKENIZER
=
lambda
{
|
value
|
value
.
split
(
//
)
}
RESERVED_OPTIONS
=
[
:minimum
,
:maximum
,
:within
,
:is
,
:tokenizer
,
:too_short
,
:too_long
]
DEFAULT_TOKENIZER
||=
->
(
value
)
{
value
.
split
(
//
)
}.
freeze
RESERVED_OPTIONS
||=
[
:minimum
,
:maximum
,
:within
,
:is
,
:tokenizer
,
:too_short
,
:too_long
].
freeze
def
initialize
(
options
)
if
range
=
(
options
.
delete
(
:in
)
||
options
.
delete
(
:within
))
...
...
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