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
1ce351ea
Commit
1ce351ea
authored
Dec 21, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move push size check to EE module
parent
168c8aa7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
39 deletions
+52
-39
ee/lib/ee/gitlab/git_access.rb
ee/lib/ee/gitlab/git_access.rb
+52
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+0
-39
No files found.
ee/lib/ee/gitlab/git_access.rb
View file @
1ce351ea
...
...
@@ -38,6 +38,19 @@ module EE
super
end
override
:check_change_access!
def
check_change_access!
return
if
changes
.
blank?
check_size_before_push!
check_if_license_blocks_changes!
super
check_push_size!
end
override
:check_active_user!
def
check_active_user!
return
if
geo?
...
...
@@ -54,6 +67,45 @@ module EE
def
geo?
actor
==
:geo
end
def
check_size_before_push!
if
check_size_limit?
&&
project
.
above_size_limit?
raise
::
Gitlab
::
GitAccess
::
UnauthorizedError
,
::
Gitlab
::
RepositorySizeError
.
new
(
project
).
push_error
end
end
def
check_if_license_blocks_changes!
if
::
License
.
block_changes?
message
=
::
LicenseHelper
.
license_message
(
signed_in:
true
,
is_admin:
(
user
&&
user
.
admin?
))
raise
::
Gitlab
::
GitAccess
::
UnauthorizedError
,
strip_tags
(
message
)
end
end
def
check_push_size!
return
unless
check_size_limit?
# If there are worktrees with a HEAD pointing to a non-existent object,
# calls to `git rev-list --all` will fail in git 2.15+. This should also
# clear stale lock files.
project
.
repository
.
clean_stale_repository_files
# rubocop: disable CodeReuse/ActiveRecord
push_size_in_bytes
=
changes_list
.
sum
do
|
change
|
repository
.
new_blobs
(
change
[
:newrev
]).
sum
(
&
:size
)
end
# rubocop: enable CodeReuse/ActiveRecord
if
project
.
changes_will_exceed_size_limit?
(
push_size_in_bytes
)
raise
::
Gitlab
::
GitAccess
::
UnauthorizedError
,
::
Gitlab
::
RepositorySizeError
.
new
(
project
).
new_changes_error
end
end
def
check_size_limit?
strong_memoize
(
:check_size_limit
)
do
project
.
size_limit_enabled?
&&
changes_list
.
any?
{
|
change
|
!::
Gitlab
::
Git
.
blank_ref?
(
change
[
:newrev
])
}
end
end
end
end
end
lib/gitlab/git_access.rb
View file @
1ce351ea
...
...
@@ -268,20 +268,7 @@ module Gitlab
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:upload
]
end
return
if
changes
.
blank?
# Allow access this is needed for EE.
if
check_size_limit?
&&
project
.
above_size_limit?
raise
UnauthorizedError
,
Gitlab
::
RepositorySizeError
.
new
(
project
).
push_error
end
if
::
License
.
block_changes?
message
=
::
LicenseHelper
.
license_message
(
signed_in:
true
,
is_admin:
(
user
&&
user
.
admin?
))
raise
UnauthorizedError
,
strip_tags
(
message
)
end
check_change_access!
check_push_size!
end
def
check_change_access!
...
...
@@ -327,25 +314,6 @@ module Gitlab
raise
TimeoutError
,
logger
.
full_message
end
def
check_push_size!
return
unless
check_size_limit?
# If there are worktrees with a HEAD pointing to a non-existent object,
# calls to `git rev-list --all` will fail in git 2.15+. This should also
# clear stale lock files.
project
.
repository
.
clean_stale_repository_files
# rubocop: disable CodeReuse/ActiveRecord
push_size_in_bytes
=
changes_list
.
sum
do
|
change
|
repository
.
new_blobs
(
change
[
:newrev
]).
sum
(
&
:size
)
end
# rubocop: enable CodeReuse/ActiveRecord
if
project
.
changes_will_exceed_size_limit?
(
push_size_in_bytes
)
raise
UnauthorizedError
,
Gitlab
::
RepositorySizeError
.
new
(
project
).
new_changes_error
end
end
def
deploy_key
actor
if
deploy_key?
end
...
...
@@ -400,13 +368,6 @@ module Gitlab
protected
def
check_size_limit?
strong_memoize
(
:check_size_limit
)
do
project
.
size_limit_enabled?
&&
changes_list
.
any?
{
|
change
|
!
Gitlab
::
Git
.
blank_ref?
(
change
[
:newrev
])
}
end
end
def
changes_list
@changes_list
||=
Gitlab
::
ChangesList
.
new
(
changes
==
ANY
?
[]
:
changes
)
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