blob: 712f1f99dcd97cbbe36608f6f4fc034ea2464702 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# frozen_string_literal: true
module Gitlab
module Checks
class PushCheck < BaseChecker
def validate!
logger.log_timed(_("Checking if you are allowed to push...")) do
unless can_push?
raise GitAccess::UnauthorizedError, GitAccess::ERROR_MESSAGES[:push_code]
end
end
end
private
def can_push?
user_access.can_do_action?(:push_code) ||
project.branch_allows_collaboration?(user_access.user, branch_name)
end
end
end
end
|