diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /lib/gitlab/checks/snippet_check.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'lib/gitlab/checks/snippet_check.rb')
-rw-r--r-- | lib/gitlab/checks/snippet_check.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/gitlab/checks/snippet_check.rb b/lib/gitlab/checks/snippet_check.rb index bcecd0fc251..8c61b782baa 100644 --- a/lib/gitlab/checks/snippet_check.rb +++ b/lib/gitlab/checks/snippet_check.rb @@ -3,7 +3,6 @@ module Gitlab module Checks class SnippetCheck < BaseChecker - DEFAULT_BRANCH = 'master'.freeze ERROR_MESSAGES = { create_delete_branch: 'You can not create or delete branches.' }.freeze @@ -11,17 +10,18 @@ module Gitlab ATTRIBUTES = %i[oldrev newrev ref branch_name tag_name logger].freeze attr_reader(*ATTRIBUTES) - def initialize(change, logger:) + def initialize(change, default_branch:, logger:) @oldrev, @newrev, @ref = change.values_at(:oldrev, :newrev, :ref) @branch_name = Gitlab::Git.branch_name(@ref) @tag_name = Gitlab::Git.tag_name(@ref) + @default_branch = default_branch @logger = logger @logger.append_message("Running checks for ref: #{@branch_name || @tag_name}") end def validate! - if creation? || deletion? + if !@default_branch || creation? || deletion? raise GitAccess::ForbiddenError, ERROR_MESSAGES[:create_delete_branch] end @@ -31,7 +31,7 @@ module Gitlab private def creation? - @branch_name != DEFAULT_BRANCH && super + @branch_name != @default_branch && super end end end |