Commit 607d55af authored by Patrick Steinhardt's avatar Patrick Steinhardt

checks: Rename ChangeAccess/BaseChecker

Both the ChangeAccess class and the BaseChecker work on a single change
only. Given that we're about to introduce batched checking, this commit
renames both classes to SingleChangeAccess and BaseSingleChecker to
highlight their nature.
parent ef418be3
......@@ -3,7 +3,7 @@
module EE
module Gitlab
module Checks
module BaseChecker
module BaseSingleChecker
extend ActiveSupport::Concern
include ::Gitlab::Utils::StrongMemoize
......
......@@ -3,7 +3,7 @@
module EE
module Gitlab
module Checks
class PushRuleCheck < ::Gitlab::Checks::BaseChecker
class PushRuleCheck < ::Gitlab::Checks::BaseSingleChecker
def validate!
return unless push_rule
......
......@@ -4,7 +4,7 @@ module EE
module Gitlab
module Checks
module PushRules
class BranchCheck < ::Gitlab::Checks::BaseChecker
class BranchCheck < ::Gitlab::Checks::BaseSingleChecker
ERROR_MESSAGE = "Branch name does not follow the pattern '%{branch_name_regex}'"
LOG_MESSAGE = "Checking if branch follows the naming patterns defined by the project..."
......
......@@ -4,7 +4,7 @@ module EE
module Gitlab
module Checks
module PushRules
class CommitCheck < ::Gitlab::Checks::BaseChecker
class CommitCheck < ::Gitlab::Checks::BaseSingleChecker
ERROR_MESSAGES = {
committer_not_verified: "Committer email '%{committer_email}' is not verified.",
committer_not_allowed: "You cannot push commits for '%{committer_email}'. You can only push commits that were committed with one of your own verified emails."
......
......@@ -4,7 +4,7 @@ module EE
module Gitlab
module Checks
module PushRules
class FileSizeCheck < ::Gitlab::Checks::BaseChecker
class FileSizeCheck < ::Gitlab::Checks::BaseSingleChecker
LOG_MESSAGE = "Checking if any files are larger than the allowed size..."
def validate!
......
......@@ -4,7 +4,7 @@ module EE
module Gitlab
module Checks
module PushRules
class TagCheck < ::Gitlab::Checks::BaseChecker
class TagCheck < ::Gitlab::Checks::BaseSingleChecker
def validate!
return unless push_rule
......
......@@ -3,7 +3,7 @@
module EE
module Gitlab
module Checks
module ChangeAccess
module SingleChangeAccess
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Gitlab::Checks::ChangeAccess do
RSpec.describe Gitlab::Checks::SingleChangeAccess do
describe '#validate!' do
include_context 'push rules checks context'
......
......@@ -2,11 +2,11 @@
module Gitlab
module Checks
class BaseChecker
class BaseSingleChecker
include Gitlab::Utils::StrongMemoize
attr_reader :change_access
delegate(*ChangeAccess::ATTRIBUTES, to: :change_access)
delegate(*SingleChangeAccess::ATTRIBUTES, to: :change_access)
def initialize(change_access)
@change_access = change_access
......@@ -57,4 +57,4 @@ module Gitlab
end
end
Gitlab::Checks::BaseChecker.prepend_mod_with('Gitlab::Checks::BaseChecker')
Gitlab::Checks::BaseSingleChecker.prepend_mod_with('Gitlab::Checks::BaseSingleChecker')
......@@ -2,7 +2,7 @@
module Gitlab
module Checks
class BranchCheck < BaseChecker
class BranchCheck < BaseSingleChecker
ERROR_MESSAGES = {
delete_default_branch: 'The default branch of a project cannot be deleted.',
force_push_protected_branch: 'You are not allowed to force push code to a protected branch on this project.',
......
......@@ -2,7 +2,7 @@
module Gitlab
module Checks
class DiffCheck < BaseChecker
class DiffCheck < BaseSingleChecker
include Gitlab::Utils::StrongMemoize
LOG_MESSAGES = {
......
......@@ -2,7 +2,7 @@
module Gitlab
module Checks
class LfsCheck < BaseChecker
class LfsCheck < BaseSingleChecker
LOG_MESSAGE = 'Scanning repository for blobs stored in LFS and verifying their files have been uploaded to GitLab...'
ERROR_MESSAGE = 'LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".'
......
......@@ -2,7 +2,7 @@
module Gitlab
module Checks
class PushCheck < BaseChecker
class PushCheck < BaseSingleChecker
def validate!
logger.log_timed("Checking if you are allowed to push...") do
unless can_push?
......
......@@ -2,7 +2,7 @@
module Gitlab
module Checks
class PushFileCountCheck < BaseChecker
class PushFileCountCheck < BaseSingleChecker
attr_reader :repository, :newrev, :limit, :logger
LOG_MESSAGES = {
......
......@@ -2,7 +2,7 @@
module Gitlab
module Checks
class ChangeAccess
class SingleChangeAccess
ATTRIBUTES = %i[user_access project skip_authorization
skip_lfs_integrity_check protocol oldrev newrev ref
branch_name tag_name logger commits].freeze
......@@ -54,4 +54,4 @@ module Gitlab
end
end
Gitlab::Checks::ChangeAccess.prepend_mod_with('Gitlab::Checks::ChangeAccess')
Gitlab::Checks::SingleChangeAccess.prepend_mod_with('Gitlab::Checks::SingleChangeAccess')
......@@ -2,7 +2,7 @@
module Gitlab
module Checks
class SnippetCheck < BaseChecker
class SnippetCheck < BaseSingleChecker
ERROR_MESSAGES = {
create_delete_branch: 'You can not create or delete branches.'
}.freeze
......
......@@ -2,7 +2,7 @@
module Gitlab
module Checks
class TagCheck < BaseChecker
class TagCheck < BaseSingleChecker
ERROR_MESSAGES = {
change_existing_tags: 'You are not allowed to change existing tags on this project.',
update_protected_tag: 'Protected tags cannot be updated.',
......
......@@ -345,7 +345,7 @@ module Gitlab
# If user does not have access to make at least one change, cancel all
# push by allowing the exception to bubble up
Checks::ChangeAccess.new(
Checks::SingleChangeAccess.new(
change,
user_access: user_access,
project: project,
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Gitlab::Checks::ChangeAccess do
RSpec.describe Gitlab::Checks::SingleChangeAccess do
describe '#validate!' do
include_context 'change access checks context'
......
......@@ -1009,7 +1009,7 @@ RSpec.describe Gitlab::GitAccess do
it 'raises TimeoutError when #check_access! raises a timeout error' do
message = "Push operation timed out\n\nTiming information for debugging purposes:\nRunning checks for ref: wow"
expect_next_instance_of(Gitlab::Checks::ChangeAccess) do |check|
expect_next_instance_of(Gitlab::Checks::SingleChangeAccess) do |check|
expect(check).to receive(:validate!).and_raise(Gitlab::Checks::TimedLogger::TimeoutError)
end
......
......@@ -12,7 +12,7 @@ RSpec.shared_context 'change access checks context' do
let(:timeout) { Gitlab::GitAccess::INTERNAL_TIMEOUT }
let(:logger) { Gitlab::Checks::TimedLogger.new(timeout: timeout) }
let(:change_access) do
Gitlab::Checks::ChangeAccess.new(
Gitlab::Checks::SingleChangeAccess.new(
changes,
project: project,
user_access: user_access,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment