debian-mirror-gitlab/lib/gitlab/checks/push_check.rb

23 lines
523 B
Ruby
Raw Normal View History

2019-02-13 22:33:31 +05:30
# 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?
2020-04-08 14:13:33 +05:30
raise GitAccess::ForbiddenError, GitAccess::ERROR_MESSAGES[:push_code]
2019-02-13 22:33:31 +05:30
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