FIX merge dev_trustie conflict
This commit is contained in:
commit
8f96341679
|
@ -1,11 +1,11 @@
|
|||
class SyncForgeController < ApplicationController
|
||||
# before_action :check_token
|
||||
|
||||
def create
|
||||
def create
|
||||
ActiveRecord::Base.transaction do
|
||||
params.permit!
|
||||
sync_params = params[:sync_params]
|
||||
project_user = User.where(login: sync_params[:owner_login])&.first
|
||||
project_user = User.where(login: sync_params[:owner_login])&.first
|
||||
#以前已同步的项目,那么肯定存在仓库
|
||||
|
||||
user_projects = Project.where(user_id: project_user.id)
|
||||
|
@ -24,12 +24,12 @@ class SyncForgeController < ApplicationController
|
|||
|
||||
if has_project
|
||||
SyncLog.sync_log("=================begin_to_update_project========")
|
||||
# project = user_projects.where(id: sync_params[:id]), identifier: sync_params[:identifier])&.first ||
|
||||
# project = user_projects.where(id: sync_params[:id]), identifier: sync_params[:identifier])&.first ||
|
||||
|
||||
check_sync_project(project, sync_params)
|
||||
else #新建项目
|
||||
SyncLog.sync_log("=================begin_to_create_new_project========")
|
||||
|
||||
|
||||
project_params = {
|
||||
repository_name: sync_params[:identifier],
|
||||
user_id: project_user.id,
|
||||
|
@ -44,16 +44,16 @@ class SyncForgeController < ApplicationController
|
|||
new_project_score = ProjectScore.create(score_params)
|
||||
SyncLog.sync_log("=================new_project_score:#{new_project_score.try(:id)}========")
|
||||
end
|
||||
|
||||
|
||||
SyncRepositoryJob.perform_later(sync_params[:owner_login], sync_params[:identifier], sync_params[:repository], get_sudomain) if sync_params[:repository].present?
|
||||
check_new_project(project, sync_params)
|
||||
else
|
||||
SyncLog.sync_project_log("=============new_project_create_failed, trustie_project_id==:#{params[:sync_params][:id]}")
|
||||
SyncLog.sync_log("=============new_project_create_failed, trustie_project_id==:#{params[:sync_params][:id]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
SyncLog.sync_project_log("=============sync_has_errors:==#{e.message}, project_id==:#{params[:sync_params][:id]}")
|
||||
SyncLog.sync_log("=============sync_has_errors:==#{e.message}, project_id==:#{params[:sync_params][:id]}")
|
||||
end
|
||||
|
||||
def sync_users
|
||||
|
@ -96,7 +96,7 @@ class SyncForgeController < ApplicationController
|
|||
# SyncLog.sync_log("=================sync_to_user_failed,user_login==#{new_user.login}")
|
||||
# end
|
||||
# else
|
||||
# SyncLog.sync_project_log("=============sync_to_user_failed,user_login====#{new_user.login}")
|
||||
# SyncLog.sync_log("=============sync_to_user_failed,user_login====#{new_user.login}")
|
||||
# SyncLog.sync_log("=================sync_to_user_failed,user_login====#{new_user.login}")
|
||||
# end
|
||||
# end
|
||||
|
@ -107,7 +107,7 @@ class SyncForgeController < ApplicationController
|
|||
SyncLog.sync_log("=================sync_user_failed====#{e}")
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def check_sync_project(project,sync_params)
|
||||
begin
|
||||
|
@ -117,8 +117,8 @@ class SyncForgeController < ApplicationController
|
|||
end
|
||||
|
||||
SyncLog.sync_log("----begin_to_check_sync_project----project_id:#{project.id}---------------")
|
||||
change_project_score(project, sync_params[:project_score], sync_params[:repository]) if sync_params[:repository].present? #更新project_score
|
||||
change_project_issues(project, sync_params[:issues],project.id, gitea_main)
|
||||
change_project_score(project, sync_params[:project_score], sync_params[:repository]) if sync_params[:repository].present? #更新project_score
|
||||
change_project_issues(project, sync_params[:issues],project.id, gitea_main)
|
||||
change_project_members(project, sync_params[:members],gitea_main)
|
||||
change_project_versions(project, sync_params[:project_versions],gitea_main)
|
||||
change_project_watchers(project, sync_params[:project_watchers],gitea_main)
|
||||
|
@ -126,7 +126,7 @@ class SyncForgeController < ApplicationController
|
|||
rescue => e
|
||||
SyncLog.sync_log("=========check_sync_project_errors:#{e}===================")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def check_new_project(project,sync_params)
|
||||
|
@ -159,7 +159,7 @@ class SyncForgeController < ApplicationController
|
|||
parent_id: project.id
|
||||
}
|
||||
SyncProjectsJob.perform_later(sync_projects_params,gitea_main)
|
||||
|
||||
|
||||
SyncLog.sync_log("***6. end_to_sync_parises---------------")
|
||||
end
|
||||
end
|
||||
|
@ -181,7 +181,7 @@ class SyncForgeController < ApplicationController
|
|||
end
|
||||
end
|
||||
pre_project_score.save! if change_num > 0 #如果 project_score有变化则更新
|
||||
else
|
||||
else
|
||||
ProjectScore.create!(project_scores.merge(project_id: project.id))
|
||||
end
|
||||
SyncLog.sync_log("***1. end_to_sync_project_score---------------")
|
||||
|
@ -217,7 +217,7 @@ class SyncForgeController < ApplicationController
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
SyncProjectsJob.perform_later(sync_projects_params, gitea_main) if sync_projects_params.present?
|
||||
SyncLog.sync_log("***2. end_to_syncissues---------------")
|
||||
rescue Exception => e
|
||||
|
@ -238,7 +238,7 @@ class SyncForgeController < ApplicationController
|
|||
parent_id: project.id
|
||||
}
|
||||
SyncProjectsJob.perform_later(sync_projects_params,gitea_main)
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
SyncLog.sync_log("***5. begin_to_sync_watchers---------------")
|
||||
|
@ -258,7 +258,7 @@ class SyncForgeController < ApplicationController
|
|||
}
|
||||
SyncProjectsJob.perform_later(sync_projects_params,gitea_main)
|
||||
end
|
||||
|
||||
|
||||
SyncLog.sync_log("***4. end_to_sync_versions---------------")
|
||||
end
|
||||
end
|
||||
|
@ -277,12 +277,12 @@ class SyncForgeController < ApplicationController
|
|||
}
|
||||
SyncProjectsJob.perform_later(sync_projects_params,gitea_main)
|
||||
end
|
||||
|
||||
|
||||
SyncLog.sync_log("***3. end_to_sync_members---------------")
|
||||
end
|
||||
end
|
||||
|
||||
# def check_token
|
||||
# def check_token
|
||||
# sync_params = params[:sync_params]
|
||||
# unless sync_params[:token] && sync_params[:token] == get_token
|
||||
# render json: {message: "token_errors"}
|
||||
|
@ -304,4 +304,4 @@ class SyncForgeController < ApplicationController
|
|||
return gitea_main
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ class SyncProjectsJob < ApplicationJob
|
|||
SyncLog.sync_log("==========begin to sync #{sync_params[:type]} to forge============")
|
||||
SyncLog.sync_log("==========sync_params:#{sync_params}============")
|
||||
|
||||
begin
|
||||
begin
|
||||
url = "#{gitea_main}/sync_forges" #trustie上的相关路由
|
||||
uri = URI.parse(url)
|
||||
http = Net::HTTP.new(uri.hostname, uri.port)
|
||||
|
@ -19,17 +19,17 @@ class SyncProjectsJob < ApplicationJob
|
|||
if response.code == '200'
|
||||
target_jsons = eval(response.body)
|
||||
if sync_params[:type] == "Project"
|
||||
SyncLog.sync_project_log("==========target_jsons: #{target_jsons}============")
|
||||
SyncLog.sync_log("==========target_jsons: #{target_jsons}============")
|
||||
update_new_project(target_jsons[:targets_params][0], sync_params[:new_project_id])
|
||||
else
|
||||
SyncLog.sync_project_log("========== #{sync_params[:type]}============")
|
||||
SyncLog.sync_log("========== #{sync_params[:type]}============")
|
||||
create_target(target_jsons[:targets_params], sync_params[:type].to_s)
|
||||
end
|
||||
else
|
||||
SyncLog.sync_project_log("==========sync_project_to_forge_failed #{sync_params[:type]}============")
|
||||
SyncLog.sync_log("==========sync_project_to_forge_failed #{sync_params[:type]}============")
|
||||
end
|
||||
rescue => e
|
||||
SyncLog.sync_project_log("==========sync_project_to_forge_failed #{sync_params[:type]}============errors:#{e}")
|
||||
SyncLog.sync_log("==========sync_project_to_forge_failed #{sync_params[:type]}============errors:#{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,19 +39,19 @@ class SyncProjectsJob < ApplicationJob
|
|||
SyncLog.sync_log("=========begin_to_update_project=project_id: #{project_id}============")
|
||||
project = Project.find_by(id: project_id)
|
||||
project.update(re[:target_params]) if re[:target_params].present?
|
||||
create_target(re[:issues_params], "Issue") if re[:issues_params].present?
|
||||
create_target(re[:member_params], "Member") if re[:member_params].present?
|
||||
create_target(re[:watcher_params], "Watcher") if re[:watcher_params].present?
|
||||
create_target(re[:praise_treads], "PraiseTread") if re[:praise_treads].present?
|
||||
create_versions(project, re[:versions_params]) if re[:versions_params].present?
|
||||
create_target(re[:issues_params], "Issue") if re[:issues_params].present?
|
||||
end
|
||||
|
||||
def create_target(target_jsons, target_type)
|
||||
begin
|
||||
SyncLog.sync_project_log("***【#{target_type}】. begin_to_create_target---------------")
|
||||
SyncLog.sync_log("***【#{target_type}】. begin_to_create_target---------------")
|
||||
return SyncLog.sync_log("*** no target_jsons") if target_jsons.blank?
|
||||
target_jsons.each_with_index do |re,index|
|
||||
SyncLog.sync_project_log("***user_login:#{re[:user_login]}----target_type:#{target_type}-----#{index+1}")
|
||||
SyncLog.sync_log("***user_login:#{re[:user_login]}----target_type:#{target_type}-----#{index+1}")
|
||||
if re[:target_params].present?
|
||||
SyncLog.sync_log("***user_login:#{re[:user_login]}----target_type:#{target_type}")
|
||||
u_id = User.select(:id, :login).where(login: re[:user_login]).pluck(:id).first
|
||||
|
@ -59,9 +59,12 @@ class SyncProjectsJob < ApplicationJob
|
|||
if target_type == "Issue"
|
||||
is_exists = Issue.exists?(author_id: u_id, project_id: re[:target_params][:project_id], subject: re[:target_params][:subject])
|
||||
unless is_exists
|
||||
version_name = re[:target_params][:re_version]
|
||||
version_id = Version.where(project_id: re[:target_params][:project_id], name: version_name)&.first&.id if version_name.present?
|
||||
assing_u_id = User.select(:id, :login).where(login: re[:assign_login]).pluck(:id).first
|
||||
new_target = target_type.constantize.new(re[:target_params].merge(author_id: u_id))
|
||||
new_target.assigned_to_id = assing_u_id
|
||||
new_target.fixed_version_id = version_id if version_id.present?
|
||||
end
|
||||
else
|
||||
case target_type
|
||||
|
@ -84,7 +87,7 @@ class SyncProjectsJob < ApplicationJob
|
|||
end
|
||||
|
||||
if !is_exists && new_target.save!
|
||||
SyncLog.sync_project_log("***【#{target_type}】. create_success---------------")
|
||||
SyncLog.sync_log("***【#{target_type}】. create_success---------------")
|
||||
if re[:journals].present?
|
||||
create_journals(re[:journals], "Journal", new_target.id)
|
||||
end
|
||||
|
@ -101,15 +104,15 @@ class SyncProjectsJob < ApplicationJob
|
|||
end
|
||||
end
|
||||
else
|
||||
SyncLog.sync_project_log("***【#{target_type}】. create_failed---or has_exists---------------")
|
||||
SyncLog.sync_log("***【#{target_type}】. create_failed---or has_exists---------------")
|
||||
end
|
||||
end
|
||||
end
|
||||
SyncLog.sync_project_log("***111222. end_to_create_target---------------")
|
||||
SyncLog.sync_log("***111222. end_to_create_target---------------")
|
||||
rescue => e
|
||||
SyncLog.sync_project_log("=========***【#{target_type}】creat_had_erros:#{e}===================")
|
||||
SyncLog.sync_log("=========***【#{target_type}】creat_had_erros:#{e}===================")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def create_journals(target_jsons, target_type,issue_id)
|
||||
|
@ -122,7 +125,7 @@ class SyncProjectsJob < ApplicationJob
|
|||
is_exists = Journal.exists?(user_id: u_id, journalized_id: re[:target_params][:journalized_id], created_on: re[:target_params][:created_on].to_s.to_time)
|
||||
|
||||
if is_exists
|
||||
SyncLog.sync_project_log("***00000. Journal:#{re[:target_params][:id]}-is exists--------------")
|
||||
SyncLog.sync_log("***00000. Journal:#{re[:target_params][:id]}-is exists--------------")
|
||||
else
|
||||
re[:target_params].delete(:id)
|
||||
new_target = Journal.new(re[:target_params].merge(user_id: u_id))
|
||||
|
@ -134,7 +137,7 @@ class SyncProjectsJob < ApplicationJob
|
|||
end
|
||||
end
|
||||
else
|
||||
SyncLog.sync_project_log("***111222. journal_create failed---------------")
|
||||
SyncLog.sync_log("***111222. journal_create failed---------------")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -151,15 +154,16 @@ class SyncProjectsJob < ApplicationJob
|
|||
u_id = User.select(:id, :login).where(login: re[:user_login]).pluck(:id).first
|
||||
is_exists = Version.exists?(user_id: u_id, project_id: re[:target_params][:project_id], created_on: re[:target_params][:created_on].to_s.to_time)
|
||||
if is_exists
|
||||
SyncLog.sync_project_log("***00000. Version:#{re[:target_params][:id]}-is exists--------------")
|
||||
SyncLog.sync_log("***00000. Version:#{re[:target_params][:id]}-is exists--------------")
|
||||
else
|
||||
re[:target_params].delete(:id)
|
||||
new_target = Version.new(re[:target_params].merge(user_id: u_id))
|
||||
if new_target.save!
|
||||
all_issues = project.issues.select(:id, :project_id, :fixed_version_id)
|
||||
all_issues&.where(fixed_version_id: old_id)&.update_all(fixed_version_id: new_target.id)
|
||||
SyncLog.sync_log("***111222. Version_create success-#{new_target.id}--------------")
|
||||
# all_issues = project.issues.select(:id, :project_id, :fixed_version_id)
|
||||
# all_issues&.where(fixed_version_id: old_id)&.update_all(fixed_version_id: new_target.id)
|
||||
else
|
||||
SyncLog.sync_project_log("***111222. Version_create failed---------------")
|
||||
SyncLog.sync_log("***111222. Version_create failed-#{old_id}--------------")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -167,4 +171,4 @@ class SyncProjectsJob < ApplicationJob
|
|||
SyncLog.sync_log("***111222. end_to_create_target---------------")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,13 +25,13 @@ class SyncRepositoryJob < ApplicationJob
|
|||
gitlab_branches.each do |branch|
|
||||
shell5 = system("cd #{path}/#{image_repo_name} && git checkout #{branch} && git push --force --set-upstream origin #{branch}")
|
||||
if !shell5
|
||||
SyncLog.sync_project_log("=============force_push_erros==#{path}/#{image_repo_name}++branch:#{branch}")
|
||||
SyncLog.sync_log("=============force_push_erros==#{path}/#{image_repo_name}++branch:#{branch}")
|
||||
else
|
||||
SyncLog.sync_project_log("=============force_push_success==#{path}/#{image_repo_name}++branch+++#{branch}")
|
||||
SyncLog.sync_log("=============force_push_success==#{path}/#{image_repo_name}++branch+++#{branch}")
|
||||
end
|
||||
end
|
||||
else
|
||||
SyncLog.sync_project_log("=============check_clone_erros==#{path}/#{image_repo_name}")
|
||||
SyncLog.sync_log("=============check_clone_erros==#{path}/#{image_repo_name}")
|
||||
SyncLog.sync_log("++++++++++++++++++check_clone_erros++++++++++++++++++#{image_repo_name}")
|
||||
end
|
||||
SyncLog.sync_log("=================end to sync repository=====================#{image_repo_name}")
|
||||
|
|
Loading…
Reference in New Issue