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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
525 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Gitlab
module Checks
2021-09-04 01:27:46 +05:30
class PushCheck < BaseSingleChecker
2019-02-15 15:39:39 +05:30
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-15 15:39:39 +05:30
end
end
end
private
def can_push?
2021-02-22 17:27:13 +05:30
user_access.can_push_for_ref?(ref) ||
2019-02-15 15:39:39 +05:30
project.branch_allows_collaboration?(user_access.user, branch_name)
end
end
end
end