FIX pull request bug

(cherry picked from commit 2b140d6f7c)
This commit is contained in:
Jasder
2021-01-12 15:45:18 +08:00
committed by moshenglv
parent 20b06473be
commit d2e2793d29
11 changed files with 219 additions and 26 deletions

View File

@@ -0,0 +1,33 @@
class PullRequests::OpenService < ApplicationService
attr_reader :owner, :repo, :pull, :current_user
# eq:
# PullRequests::OpenService.call(owner, repo, pull, current_user)
def initialize(owner, repo, pull, current_user)
@owner = owner
@repo = repo
@pull = pull
@current_user = current_user
end
def call
ActiveRecord::Base.transaction do
return false if open_gitea_pull[:status] != :success
update_pull_status!
return true
end
end
private
def open_gitea_pull
Gitea::PullRequest::OpenService.call(@owner.login, @repo.identifier,
@pull.gpid, @pull.base, @current_user.gitea_token)
end
def update_pull_status!
@pull.update(status: PullRequest::OPEN)
@pull.issue.update(status_id: IssueStatus::SOLVING)
end
end