From 3d933634e3cc16ea602e0a2dcfe7eda50dc85c78 Mon Sep 17 00:00:00 2001 From: jasder duan Date: Thu, 24 Oct 2024 15:12:09 +0800 Subject: [PATCH] =?UTF-8?q?FIX=20=E5=A4=84=E7=90=86=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E6=98=AF=E5=90=A6=E8=83=BD?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E7=9A=84=E6=93=8D=E4=BD=9C=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 6 ++++++ app/views/pull_requests/show.json.jbuilder | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index ec0763875..2dc19c291 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -175,6 +175,12 @@ class PullRequestsController < ApplicationController @gitea_pull = Gitea::PullRequest::GetService.call(@owner.login, @repository.identifier, @pull_request.gitea_number, @owner&.gitea_token) # @last_review = @pull_request.reviews.take + begin + @base_branch = Gitea::Repository::Branches::GetService.call(@project.owner, @project.identifier, @pull_request.base, current_user&.gitea_token) + rescue StandardError => e + Rails.logger.info "pull_request get base branch error: #{e.message}" + @base_branch = {} + end end def pr_merge diff --git a/app/views/pull_requests/show.json.jbuilder b/app/views/pull_requests/show.json.jbuilder index a758337de..1d2d317bf 100644 --- a/app/views/pull_requests/show.json.jbuilder +++ b/app/views/pull_requests/show.json.jbuilder @@ -7,6 +7,10 @@ json.commits_count @gitea_pull["commit_num"] json.files_count @gitea_pull["changed_files"] json.comments_count @issue.journals.parent_journals.size json.comments_total_count @issue.get_journals_size + +json.user_can_push @base_branch["user_can_push"] | false # base分支是否可以push +json.user_can_merge @base_branch["user_can_merge"] | false # base分支是否可以合并PR + json.assign_user do json.partial! 'users/user_simple', user: @issue_assign_to end