diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-03 18:09:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-03 18:09:46 +0300 |
commit | bbd9e2c915c46920ceb51376db19599cbf9ba836 (patch) | |
tree | 897c9abbe0afa31f077dd7ca7c76ba755b75237a /lib/gitlab/checks/snippet_check.rb | |
parent | f145ef4be75f3711c52a680b86d96568e9acf385 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/checks/snippet_check.rb')
-rw-r--r-- | lib/gitlab/checks/snippet_check.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/gitlab/checks/snippet_check.rb b/lib/gitlab/checks/snippet_check.rb index 54aee7f6ef7..d5efbfcc5bc 100644 --- a/lib/gitlab/checks/snippet_check.rb +++ b/lib/gitlab/checks/snippet_check.rb @@ -10,12 +10,13 @@ module Gitlab ATTRIBUTES = %i[oldrev newrev ref branch_name tag_name logger].freeze attr_reader(*ATTRIBUTES) - def initialize(change, default_branch:, logger:) + def initialize(change, default_branch:, root_ref:, 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 + @root_ref = root_ref @logger = logger @logger.append_message("Running checks for ref: #{@branch_name || @tag_name}") end @@ -34,8 +35,13 @@ module Gitlab private + # If the `root_ref` is not present means that this is the first commit to the + # repository and when the default branch is going to be created. + # We allow the first branch creation no matter the name because + # it can be even an imported snippet from an instance with a different + # default branch. def creation? - @branch_name != @default_branch && super + super && @root_ref && (@branch_name != @default_branch) end end end |