2021-05-12 03:10:21 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Base class, scoped by project
|
|
|
|
class BaseProjectService < ::BaseContainerService
|
2021-10-06 18:12:19 +00:00
|
|
|
include ::Gitlab::Utils::StrongMemoize
|
|
|
|
|
2021-05-12 03:10:21 +00:00
|
|
|
attr_accessor :project
|
|
|
|
|
|
|
|
def initialize(project:, current_user: nil, params: {})
|
2022-09-29 21:08:27 +00:00
|
|
|
# we need to exclude project params since they may come from external requests. project should always
|
|
|
|
# be passed as part of the service's initializer
|
|
|
|
super(container: project, current_user: current_user, params: params.except(:project, :project_id))
|
2021-05-12 03:10:21 +00:00
|
|
|
|
|
|
|
@project = project
|
|
|
|
end
|
|
|
|
|
|
|
|
delegate :repository, to: :project
|
2021-10-06 18:12:19 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project_group
|
|
|
|
strong_memoize(:project_group) do
|
|
|
|
project.group
|
|
|
|
end
|
|
|
|
end
|
2021-05-12 03:10:21 +00:00
|
|
|
end
|