Merge branch 'dev_trustie' of http://gitea.trustie.net/jasder/forgeplus into dev_trustie

This commit is contained in:
sylor_huang@126.com 2020-06-23 14:57:06 +08:00
commit 33d87b0c93
4 changed files with 15 additions and 20 deletions

View File

@ -25,10 +25,8 @@ class ProjectsController < ApplicationController
end
def migrate
ActiveRecord::Base.transaction do
Projects::MigrateForm.new(mirror_params).validate!
@project = Projects::MigrateService.new(current_user, mirror_params).call
end
Projects::MigrateForm.new(mirror_params).validate!
@project = Projects::MigrateService.new(current_user, mirror_params).call
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)

View File

@ -8,7 +8,7 @@ class MigrateRemoteRepositoryJob < ApplicationJob
gitea_repository = Gitea::Repository::MigrateService.new(token, params).call
if gitea_repository
repo&.project&.update_columns(gpid: gitea_repository["id"], identifier: gitea_repository["name"])
repo&.project&.update_columns(gpid: gitea_repository["id"])
repo&.mirror&.update_columns(status: Mirror.statuses[:succeeded])
end
end

View File

@ -8,12 +8,10 @@ class Projects::MigrateService < ApplicationService
def call
@project = Project.new(project_params)
ActiveRecord::Base.transaction do
if @project.save!
Repositories::MigrateService.new(user, @project, repository_params).call
else
#
end
if @project.save!
Repositories::MigrateService.new(user, @project, repository_params).call
else
#
end
@project
rescue => e
@ -27,11 +25,12 @@ class Projects::MigrateService < ApplicationService
{
name: params[:name],
user_id: params[:user_id],
project_type: set_project_type,
description: params[:description],
identifier: params[:repository_name],
is_public: project_secretion[:public],
project_category_id: params[:project_category_id],
project_language_id: params[:project_language_id],
is_public: project_secretion[:public],
project_type: set_project_type
}
end

View File

@ -9,13 +9,11 @@ class Repositories::MigrateService < ApplicationService
def call
@repository = Repository.new(repository_params)
ActiveRecord::Base.transaction do
if @repository.save!
@repository.set_mirror! if wrapper_mirror
MigrateRemoteRepositoryJob.perform_later(@repository.id, user.gitea_token, gitea_repository_params)
end
@repository
if @repository.save!
@repository.set_mirror! if wrapper_mirror
MigrateRemoteRepositoryJob.perform_later(@repository.id, user.gitea_token, gitea_repository_params)
end
@repository
rescue => e
puts "create mirror repository service error: #{e.message}"
raise Error, e.message
@ -23,7 +21,7 @@ class Repositories::MigrateService < ApplicationService
private
def repository_params
params.merge(project_id: project.id)
params.merge(project_id: project.id, identifier: params[:identifier])
end
def gitea_repository_params