Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 18:09:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 18:09:24 +0300
commitf8d15ca65390475e356b06dedc51e10ccd179f86 (patch)
treeef916d4e8e11c9e00d809e5cdcf63814e86d6e89 /lib/gitlab/checks
parent3ab4feda4dce9c9f0672375ae27c2f7c2ba6f4ad (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r--lib/gitlab/checks/snippet_check.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/gitlab/checks/snippet_check.rb b/lib/gitlab/checks/snippet_check.rb
new file mode 100644
index 00000000000..26dd772764a
--- /dev/null
+++ b/lib/gitlab/checks/snippet_check.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Checks
+ class SnippetCheck < BaseChecker
+ ERROR_MESSAGES = {
+ create_delete_branch: 'You can not create or delete branches.'
+ }.freeze
+
+ ATTRIBUTES = %i[oldrev newrev ref branch_name tag_name logger].freeze
+ attr_reader(*ATTRIBUTES)
+
+ def initialize(change, logger:)
+ @oldrev, @newrev, @ref = change.values_at(:oldrev, :newrev, :ref)
+ @branch_name = Gitlab::Git.branch_name(@ref)
+ @tag_name = Gitlab::Git.tag_name(@ref)
+
+ @logger = logger
+ @logger.append_message("Running checks for ref: #{@branch_name || @tag_name}")
+ end
+
+ def exec
+ if creation? || deletion?
+ raise GitAccess::UnauthorizedError, ERROR_MESSAGES[:create_delete_branch]
+ end
+
+ # TODO: https://gitlab.com/gitlab-org/gitlab/issues/205628
+ # Check operation will not result in more than one file in the repository
+
+ true
+ end
+ end
+ end
+end