add: sync mirror project remove pulls module
This commit is contained in:
parent
fc5876fc32
commit
e490ddb1f5
|
@ -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!)
|
||||
|
|
|
@ -10,7 +10,7 @@ class Projects::MigrateService < ApplicationService
|
|||
def call
|
||||
@project = Project.new(project_params)
|
||||
if @project.save!
|
||||
ProjectUnit.init_types(@project.id)
|
||||
ProjectUnit.init_types(@project.id, project.project_type)
|
||||
Project.update_mirror_projects_count!
|
||||
@project.set_owner_permission(user)
|
||||
Repositories::MigrateService.new(user, @project, repository_params).call
|
||||
|
|
Loading…
Reference in New Issue