Merge pull request '代码仓库同步部分代码' (#282) from reposync_feature into standalone_develop

This commit is contained in:
2024-05-10 15:05:04 +08:00
33 changed files with 952 additions and 5 deletions

View File

@@ -0,0 +1,12 @@
json.total_count @group_sync_repository_branch.count
json.sync_repository_branches @group_sync_repository_branch.each do |item|
json.gitlink_branch_name item.gitlink_branch_name
json.external_branch_name item.external_branch_name
branches = @sync_repository_branches.joins(:sync_repository).where(sync_repositories: {type: item.type}, 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.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)
end

View File

@@ -0,0 +1,5 @@
json.gitlink_repo_address "#{EduSetting.get("gitlink_repo_domain")}/#{@project.owner&.login}/#{@project.identifier}.git"
json.external_repo_address @sync_repository1.external_repo_address
json.sync_granularity @sync_repository1.sync_granularity
json.gitlink_branch_name @sync_repository_branch1&.gitlink_branch_name
json.external_branch_name @sync_repository_branch1&.external_branch_name

View File

@@ -0,0 +1,12 @@
json.total_count @total_count
json.gitlink_branch_name @branch&.gitlink_branch_name
json.external_type @branch&.sync_repository&.type
json.external_branch_name @branch&.external_branch_name
json.logs @reposync_branch_logs.each do |log|
type = log['repo_name'].start_with?('gitee') ? 'gitee' : 'github'
json.change_from log['sync_direct'] == "to_inter" ? type : 'gitlink'
json.commit_id log['commit_id']
json.sync_time log['update_at']
json.log log['log']
json.sync_status log['log'].include?("************ 分支同步完成 ************") ? 'success' : "failure"
end

View File

@@ -0,0 +1,8 @@
json.total_count @group_sync_repository.keys.count
json.sync_repositories @group_sync_repository.each do |key|
json.type key[0][0]
json.external_repo_address key[0][1]
json.sync_granularity key[0][2]
json.external_token key[0][3]
json.sync_repository_ids @sync_repositories.where(type: key[0][0], external_repo_address: key[0][1], sync_granularity: key[0][2]).pluck(:id)
end