Browse Source

chang

tags/v1.0.0
sylor_huang@126.com 6 years ago
parent
commit
d12fc65da5
3 changed files with 9 additions and 7 deletions
  1. +4
    -6
      app/controllers/sync_forge_controller.rb
  2. +0
    -1
      app/jobs/sync_repository_job.rb
  3. +5
    -0
      app/models/sync_log.rb

+ 4
- 6
app/controllers/sync_forge_controller.rb View File

@@ -2,7 +2,6 @@ class SyncForgeController < ApplicationController
before_action :check_token

def create
ActiveRecord::Base.transaction do
params.permit!
sync_params = params[:sync_params]
@@ -22,7 +21,6 @@ class SyncForgeController < ApplicationController
name: sync_params[:name]
}
project = Projects::CreateService.new(project_user, project_params).call
Rails.logger.info("=================new_project_id:#{project.id}========")
if project.present?
if sync_params[:project_score].present?
sync_params.permit!
@@ -37,7 +35,7 @@ class SyncForgeController < ApplicationController
end
end
rescue Exception => e
Rails.logger.info("=================has_errors:==#{e.message}")
SyncLog.sync_project_log("=============sync_has_errors:==#{e.message}, project_id==:#{params[:sync_params][:id]}")
end

def sync_users
@@ -61,12 +59,12 @@ class SyncForgeController < ApplicationController
new_user.gitea_uid = gitea_user['id']
if new_user.save!
UserExtension.create!(u[:user_extensions].merge(user_id: new_user.id)) if u[:user_extensions].present?
SyncLog.sync_log("=================sync_to_user_success====#{new_user.login}")
else
SyncLog.sync_log("=================sync_to_user_failed==1==#{new_user.login}")
SyncLog.sync_log("=================sync_to_user_failed,user_login==#{new_user.login}")
end
else
SyncLog.sync_log("=================sync_to_user_failed====#{new_user.login}")
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}")
end
end
end


+ 0
- 1
app/jobs/sync_repository_job.rb View File

@@ -23,7 +23,6 @@ class SyncRepositoryJob < ApplicationJob
SyncLog.sync_log("========check_clone:====cd #{path} && git clone #{image_url}===================")
if check_clone
new_gitlab_url = "http://root:_Trustie_10010@#{gitea_main}/#{user_login}/#{identifier}.git"

shell_remote_1 = system("cd #{path}/#{image_repo_name} && git remote set-url origin #{new_gitlab_url}")
shell5 = system("cd #{path}/#{image_repo_name} && git checkout #{g_default_branch} && git push --force --set-upstream origin #{g_default_branch}")


+ 5
- 0
app/models/sync_log.rb View File

@@ -3,4 +3,9 @@ class SyncLog
@my_log ||= Logger.new("#{Rails.root}/log/sync.log")
@my_log.debug(message) unless message.nil?
end

def self.sync_project_log(message=nil)
@my_log ||= Logger.new("#{Rails.root}/log/sync_error_project.log")
@my_log.debug(message) unless message.nil?
end
end

Loading…
Cancel
Save