[FIX]transfer need to save clone_url

This commit is contained in:
Gitea 2021-02-21 10:02:47 +08:00
parent 9f4c2bd673
commit 11471b1520
1 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,5 @@
class Projects::TransferService < ApplicationService
attr_accessor :project, :owner, :new_owner
attr_accessor :project, :owner, :new_owner, :gitea_repo
def initialize(project, new_owner)
@project = project
@ -12,6 +12,7 @@ class Projects::TransferService < ApplicationService
ActiveRecord::Base.transaction do
gitea_update_owner
update_owner
update_repo_url
update_visit_teams
end
@ -25,6 +26,10 @@ class Projects::TransferService < ApplicationService
project.update!(user_id: new_owner.id)
end
def update_repo_url
project.repository.update!(url: @gitea_repo["clone_url"])
end
def update_visit_teams
if new_owner.is_a?(Organization)
new_owner.teams.where(includes_all_project: true).each do |team|
@ -37,7 +42,7 @@ class Projects::TransferService < ApplicationService
def gitea_update_owner
begin
Gitea::Repository::TransferService.call(owner&.gitea_token, owner&.login, project.identifier, new_owner&.login)
@gitea_repo = Gitea::Repository::TransferService.call(owner&.gitea_token, owner&.login, project.identifier, new_owner&.login)
rescue Exception => e
Rails.logger.info("##### Project transfer_service, gitea transfer error #{e}")
end