|
|
|
@@ -20,13 +20,16 @@ class ProjectUnit < ApplicationRecord |
|
|
|
|
|
|
|
validates :unit_type, uniqueness: { scope: :project_id} |
|
|
|
|
|
|
|
def self.init_types(project_id) |
|
|
|
ProjectUnit::unit_types.each do |_, v| |
|
|
|
def self.init_types(project_id, project_type='common') |
|
|
|
unit_types = project_type == 'sync_mirror' ? ProjectUnit::unit_types.except("pulls") : ProjectUnit::unit_types |
|
|
|
unit_types.each do |_, v| |
|
|
|
self.create!(project_id: project_id, unit_type: v) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def self.update_by_unit_types!(project, types) |
|
|
|
# 同步镜像项目不能有合并请求模块 |
|
|
|
types.delete("pulls") if project.sync_mirror? |
|
|
|
# 默认code类型自动创建 |
|
|
|
types << "code" |
|
|
|
project.project_units.where.not(unit_type: types).each(&:destroy!) |
|
|
|
|