新增:更改同步分支状态首次同步方向
This commit is contained in:
parent
0f5066f943
commit
946b449d9d
|
@ -17,9 +17,10 @@ class Api::V1::Projects::SyncRepositoriesController < Api::V1::BaseController
|
|||
return render_error("请输入正确的同步方向!") if params[:sync_direction].blank?
|
||||
@sync_repositories = SyncRepository.where(project: @project, sync_direction: params[:sync_direction])
|
||||
@sync_repository_branches = SyncRepositoryBranch.where(sync_repository_id: @sync_repositories, enable: true)
|
||||
@sync_repositories.each do |item|
|
||||
TouchSyncJob.perform_later(item)
|
||||
end
|
||||
# 全部分支同步暂时不做
|
||||
# @sync_repositories.each do |item|
|
||||
# TouchSyncJob.perform_later(item)
|
||||
# end
|
||||
@sync_repository_branches.each do |item|
|
||||
TouchSyncJob.perform_later(item)
|
||||
end
|
||||
|
@ -44,10 +45,12 @@ class Api::V1::Projects::SyncRepositoriesController < Api::V1::BaseController
|
|||
def change_enable
|
||||
return render_error("请输入正确的分支名称") if params[:gitlink_branch_name].blank? || params[:external_branch_name].blank?
|
||||
return render_error("请输入正确的状态") if params[:enable].blank?
|
||||
@sync_repository_branches = SyncRepositoryBranch.where(gitlink_branch_name: params[:gitlink_branch_name], external_branch_name: params[:external_branch_name])
|
||||
@sync_repository_branches = SyncRepositoryBranch.joins(:sync_repository).where(sync_repositories: {project_id: @project.id}, gitlink_branch_name: params[:gitlink_branch_name], external_branch_name: params[:external_branch_name])
|
||||
if @sync_repository_branches.update_all({enable: params[:enable]})
|
||||
@sync_repository_branches.each do |branch|
|
||||
if branch&.sync_repository&.sync_direction.to_i == 1
|
||||
branch_sync_direction = branch&.sync_repository&.sync_direction.to_i
|
||||
TouchSyncJob.perform_later(branch) if params[:enable] && branch_sync_direction == params[:first_sync_direction].to_i
|
||||
if branch_sync_direction == 1
|
||||
Reposync::UpdateBranchStatusService.call(branch&.sync_repository&.repo_name, branch.gitlink_branch_name, params[:enable])
|
||||
else
|
||||
Reposync::UpdateBranchStatusService.call(branch&.sync_repository&.repo_name, branch.external_branch_name, params[:enable])
|
||||
|
|
|
@ -5,7 +5,7 @@ json.sync_repository_branches @group_sync_repository_branch.each do |item|
|
|||
branches = @sync_repository_branches.where(gitlink_branch_name: item.gitlink_branch_name, external_branch_name: item.external_branch_name).order(updated_at: :desc)
|
||||
branch = branches.first
|
||||
json.type branch&.sync_repository&.type
|
||||
json.sync_time branch.sync_time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
json.sync_time branch.sync_time.present? ? branch.sync_time.strftime("%Y-%m-%d %H:%M:%S") : nil
|
||||
json.sync_status branch.sync_status
|
||||
json.enable branch.enable
|
||||
json.reposync_branch_ids branches.pluck(:reposync_branch_id)
|
||||
|
|
Loading…
Reference in New Issue