Class: Gitlab::Checks::ChangeAccess

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/checks/change_access.rb

Constant Summary collapse

ATTRIBUTES =
%i[user_access project skip_authorization
skip_lfs_integrity_check protocol oldrev newrev ref
branch_name tag_name logger commits].freeze

Instance Method Summary collapse

Constructor Details

#initialize(change, user_access:, project:, skip_lfs_integrity_check: false, protocol:, logger:) ⇒ ChangeAccess

Returns a new instance of ChangeAccess.


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/checks/change_access.rb', line 12

def initialize(
  change, user_access:, project:,
  skip_lfs_integrity_check: false, protocol:, logger:
)
  @oldrev, @newrev, @ref = change.values_at(:oldrev, :newrev, :ref)
  @branch_name = Gitlab::Git.branch_name(@ref)
  @tag_name = Gitlab::Git.tag_name(@ref)
  @user_access = user_access
  @project = project
  @skip_lfs_integrity_check = skip_lfs_integrity_check
  @protocol = protocol

  @logger = logger
  @logger.append_message("Running checks for ref: #{@branch_name || @tag_name}")
end

Instance Method Details

#commitsObject


37
38
39
# File 'lib/gitlab/checks/change_access.rb', line 37

def commits
  @commits ||= project.repository.new_commits(newrev)
end

#validate!Object


28
29
30
31
32
33
34
35
# File 'lib/gitlab/checks/change_access.rb', line 28

def validate!
  ref_level_checks
  # Check of commits should happen as the last step
  # given they're expensive in terms of performance
  commits_check

  true
end