Merge branch 'dev_trustie' into dev_chain
This commit is contained in:
commit
3fe0c4752f
|
@ -41,12 +41,11 @@ class SyncProjectsJob < ApplicationJob
|
||||||
project.update(re[:target_params]) if re[:target_params].present?
|
project.update(re[:target_params]) if re[:target_params].present?
|
||||||
create_target(re[:issues_params], "Issue") if re[:issues_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[:member_params], "Member") if re[:member_params].present?
|
||||||
create_target(re[:versions_params], "Version") if re[:versions_params].present?
|
|
||||||
create_target(re[:watcher_params], "Watcher") if re[:watcher_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_target(re[:praise_treads], "PraiseTread") if re[:praise_treads].present?
|
||||||
|
create_versions(project, re[:versions_params]) if re[:versions_params].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def create_target(target_jsons, target_type)
|
def create_target(target_jsons, target_type)
|
||||||
SyncLog.sync_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?
|
return SyncLog.sync_log("*** no target_jsons") if target_jsons.blank?
|
||||||
|
@ -54,8 +53,7 @@ class SyncProjectsJob < ApplicationJob
|
||||||
if re[:target_params].present?
|
if re[:target_params].present?
|
||||||
SyncLog.sync_log("***user_login:#{re[:user_login]}----target_type:#{target_type}")
|
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
|
u_id = User.select(:id, :login).where(login: re[:user_login]).pluck(:id).first
|
||||||
new_target = target_type.constantize.new(re[:target_params].merge(user_id: u_id))
|
new_target = target_type.constantize.new(re[:target_params].delete(:id).merge(user_id: u_id))
|
||||||
|
|
||||||
if target_type == "Issue"
|
if target_type == "Issue"
|
||||||
assing_u_id = User.select(:id, :login).where(login: re[:assign_login]).pluck(:id).first
|
assing_u_id = User.select(:id, :login).where(login: re[:assign_login]).pluck(:id).first
|
||||||
new_target.assigned_to_id = assing_u_id
|
new_target.assigned_to_id = assing_u_id
|
||||||
|
@ -74,4 +72,23 @@ class SyncProjectsJob < ApplicationJob
|
||||||
end
|
end
|
||||||
SyncLog.sync_log("***111222. end_to_create_target---------------")
|
SyncLog.sync_log("***111222. end_to_create_target---------------")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_versions(project, target_jsons)
|
||||||
|
SyncLog.sync_log("***【Versions】. begin_to_create_verison---------------")
|
||||||
|
return SyncLog.sync_log("*** no target_jsons") if target_jsons.blank?
|
||||||
|
all_issues = project.issues.select(:id, :project_id, :fixed_version_id)
|
||||||
|
target_jsons.each do |re|
|
||||||
|
old_id = re[:target_params][:id]
|
||||||
|
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
|
||||||
|
new_target = target_type.constantize.new(re[:target_params].delete(:id).merge(user_id: u_id))
|
||||||
|
if new_target.save!
|
||||||
|
all_issues&.where(fixed_version_id: old_id)&.update_all(fixed_version_id: new_target.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
SyncLog.sync_log("***111222. end_to_create_target---------------")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -7,12 +7,18 @@ class SyncRepositoryJob < ApplicationJob
|
||||||
#创建临时文件夹 clone 并强推代码
|
#创建临时文件夹 clone 并强推代码
|
||||||
SyncLog.sync_log("=================begin to sync request trustie repository=====================")
|
SyncLog.sync_log("=================begin to sync request trustie repository=====================")
|
||||||
path = "#{Rails.root}/public/cache_repository"
|
path = "#{Rails.root}/public/cache_repository"
|
||||||
unless File.directory?(path)
|
|
||||||
FileUtils.mkdir_p(path)
|
|
||||||
end
|
|
||||||
image_url = repository_params[:git_url]
|
image_url = repository_params[:git_url]
|
||||||
g_default_branch = repository_params[:default_branch]
|
g_default_branch = repository_params[:default_branch]
|
||||||
image_repo_name = image_url.to_s.split('/')&.last&.chomp('.git')
|
image_repo_name = image_url.to_s.split('/')&.last&.chomp('.git')
|
||||||
|
|
||||||
|
unless File.directory?(path)
|
||||||
|
FileUtils.mkdir_p(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
if Dir.exist?("#{path}/#{image_repo_name}")
|
||||||
|
system("rm -rf #{path}/#{image_repo_name}")
|
||||||
|
end
|
||||||
|
|
||||||
check_clone = system("cd #{path} and git clone #{image_url}")
|
check_clone = system("cd #{path} and git clone #{image_url}")
|
||||||
SyncLog.sync_log("========check_clone:====cd #{path} and git clone #{image_url}===================")
|
SyncLog.sync_log("========check_clone:====cd #{path} and git clone #{image_url}===================")
|
||||||
if check_clone
|
if check_clone
|
||||||
|
|
Loading…
Reference in New Issue