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
3b8daba1
Commit
3b8daba1
authored
Jan 19, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly convert values to deal with Bytes
parent
aedac4e8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
9 deletions
+11
-9
app/controllers/concerns/lfs_request.rb
app/controllers/concerns/lfs_request.rb
+1
-1
app/models/project.rb
app/models/project.rb
+4
-2
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+1
-1
lib/gitlab/repository_size_error.rb
lib/gitlab/repository_size_error.rb
+1
-1
spec/lib/gitlab/repository_size_error_spec.rb
spec/lib/gitlab/repository_size_error_spec.rb
+2
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-2
No files found.
app/controllers/concerns/lfs_request.rb
View file @
3b8daba1
...
...
@@ -136,7 +136,7 @@ module LfsRequest
size_of_objects
=
objects
.
sum
{
|
o
|
o
[
:size
]
}
@limit_exceeded
=
(
project
.
repository_and_lfs_size
+
size_of_objects
.
to_mb
)
>
project
.
actual_size_limit
@limit_exceeded
=
(
project
.
repository_and_lfs_size
+
size_of_objects
)
>
project
.
actual_size_limit
end
end
...
...
app/models/project.rb
View file @
3b8daba1
...
...
@@ -1541,8 +1541,10 @@ class Project < ActiveRecord::Base
actual_size_limit
!=
0
end
def
changes_will_exceed_size_limit?
(
size_mb
)
size_limit_enabled?
&&
(
size_mb
>
actual_size_limit
||
size_mb
+
repository_and_lfs_size
>
actual_size_limit
)
def
changes_will_exceed_size_limit?
(
size_in_bytes
)
size_limit_enabled?
&&
(
size_in_bytes
>
actual_size_limit
||
size_in_bytes
+
repository_and_lfs_size
>
actual_size_limit
)
end
def
environments_for
(
ref
,
commit:
nil
,
with_tags:
false
)
...
...
lib/gitlab/git_access.rb
View file @
3b8daba1
...
...
@@ -185,7 +185,7 @@ module Gitlab
end
end
if
project
.
changes_will_exceed_size_limit?
(
push_size_in_bytes
.
to_mb
)
if
project
.
changes_will_exceed_size_limit?
(
push_size_in_bytes
)
raise
UnauthorizedError
,
Gitlab
::
RepositorySizeError
.
new
(
project
).
new_changes_error
end
end
...
...
lib/gitlab/repository_size_error.rb
View file @
3b8daba1
...
...
@@ -55,7 +55,7 @@ module Gitlab
end
def
format_number
(
number
)
number_to_human_size
(
number
*
1
.
megabyte
,
delimiter:
','
,
precision:
2
)
number_to_human_size
(
number
,
delimiter:
','
,
precision:
2
)
end
end
end
spec/lib/gitlab/repository_size_error_spec.rb
View file @
3b8daba1
...
...
@@ -2,14 +2,14 @@ require 'spec_helper'
describe
Gitlab
::
RepositorySizeError
,
lib:
true
do
let
(
:project
)
do
create
(
:empty_project
,
statistics:
build
(
:project_statistics
,
repository_size:
15
))
create
(
:empty_project
,
statistics:
build
(
:project_statistics
,
repository_size:
15
.
megabytes
))
end
let
(
:message
)
{
Gitlab
::
RepositorySizeError
.
new
(
project
)
}
let
(
:base_message
)
{
'because this repository has exceeded its size limit of 10 MB by 5 MB'
}
before
do
allow
(
project
).
to
receive
(
:actual_size_limit
).
and_return
(
10
)
allow
(
project
).
to
receive
(
:actual_size_limit
).
and_return
(
10
.
megabytes
)
end
describe
'error messages'
do
...
...
spec/models/project_spec.rb
View file @
3b8daba1
...
...
@@ -573,13 +573,13 @@ describe Project, models: true do
group
=
create
(
:group
,
repository_size_limit:
100
)
project
.
update_attribute
(
:namespace_id
,
group
.
id
)
expect
(
project
.
actual_size_limit
).
to
eq
(
100
)
expect
(
project
.
actual_size_limit
).
to
eq
(
100
.
megabytes
)
end
it
'returns the value set locally'
do
project
.
update_attribute
(
:repository_size_limit
,
75
)
expect
(
project
.
actual_size_limit
).
to
eq
(
75
)
expect
(
project
.
actual_size_limit
).
to
eq
(
75
.
megabytes
)
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