Class: MergeRequests::Mergeability::CheckLfsFileLocksService

Inherits:
CheckBaseService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/merge_requests/mergeability/check_lfs_file_locks_service.rb

Constant Summary collapse

CACHE_KEY =
'merge_request:%{id}:%{sha}:lfs_file_locks_mergeability:%{epoch}'

Instance Attribute Summary

Attributes inherited from CheckBaseService

#merge_request, #params

Instance Method Summary collapse

Methods inherited from CheckBaseService

description, identifier, #initialize

Constructor Details

This class inherits a constructor from MergeRequests::Mergeability::CheckBaseService

Instance Method Details

#cache_keyObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/services/merge_requests/mergeability/check_lfs_file_locks_service.rb', line 30

def cache_key
  # If the feature is disabled we will return inactive so we don't need to
  # link the cache key to a specific MR.
  return 'inactive_lfs_file_locks_mergeability_check' if check_inactive?

  # Cache is linked to a specific MR
  id = merge_request.id
  # Cache is invalidated when new changes are added
  sha = merge_request.diff_head_sha
  # Cache is invalidated when lfs_file_locks are added or removed
  epoch = project.lfs_file_locks_changed_epoch

  format(CACHE_KEY, id: id, sha: sha, epoch: epoch)
end

#cacheable?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/services/merge_requests/mergeability/check_lfs_file_locks_service.rb', line 26

def cacheable?
  true
end

#executeObject



15
16
17
18
19
20
# File 'app/services/merge_requests/mergeability/check_lfs_file_locks_service.rb', line 15

def execute
  return inactive if check_inactive?
  return failure if contains_locked_lfs_files?

  success
end

#skip?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/services/merge_requests/mergeability/check_lfs_file_locks_service.rb', line 22

def skip?
  params[:skip_locked_lfs_files_check].present?
end