2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DesignManagement
|
2023-06-20 00:43:36 +05:30
|
|
|
class Repository < ApplicationRecord
|
|
|
|
include ::Gitlab::Utils::StrongMemoize
|
2023-07-09 08:55:56 +05:30
|
|
|
include HasRepository
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
belongs_to :project, inverse_of: :design_management_repository
|
|
|
|
validates :project, presence: true, uniqueness: true
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
delegate :lfs_enabled?, :storage, :repository_storage, to: :project
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
def repository
|
|
|
|
::DesignManagement::GitRepository.new(
|
|
|
|
full_path,
|
|
|
|
self,
|
|
|
|
shard: repository_storage,
|
|
|
|
disk_path: disk_path,
|
|
|
|
repo_type: repo_type
|
|
|
|
)
|
|
|
|
end
|
|
|
|
strong_memoize_attr :repository
|
|
|
|
|
|
|
|
def full_path
|
|
|
|
project.full_path + repo_type.path_suffix
|
|
|
|
end
|
|
|
|
|
|
|
|
def disk_path
|
|
|
|
project.disk_path + repo_type.path_suffix
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
def repo_type
|
|
|
|
Gitlab::GlRepository::DESIGN
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|