Browse Source

新增:返回是否有合并请求字段

pull/347/head
yystopf 1 year ago
parent
commit
6dda125a1c
2 changed files with 10 additions and 1 deletions
  1. +9
    -0
      app/models/project.rb
  2. +1
    -1
      app/views/api/v1/projects/branches/index.json.jbuilder

+ 9
- 0
app/models/project.rb View File

@@ -462,6 +462,15 @@ class Project < ApplicationRecord
EduSetting.get("open_portrait_projects").present? ? EduSetting.get("open_portrait_projects").split(",").include?(self.id.to_s) : false
end

def has_pull_request(branch_name)
return true if self.pull_requests.opening.where(head: branch_name).present? || self.pull_requests.opening.where(base: branch_name).present?
if self.forked_from_project_id.present?
return true if self.fork_project.pull_requests.opening.where(head: branch_name).present? || self.fork_project.pull_requests.opening.where(base: branch_name).present?
end

return false
end

def self.mindspore_contributors
cache_result = $redis_cache.get("ProjectMindsporeContributors")
if cache_result.nil?


+ 1
- 1
app/views/api/v1/projects/branches/index.json.jbuilder View File

@@ -1,5 +1,5 @@
json.total_count @result_object[:total_data].to_i
json.branches @result_object[:data].each do |branch|
json.partial! "api/v1/projects/branches/simple_gitea_detail", branch: branch, default_branch: @result_object[:default_branch]
json.has_pull_request @project.has_pull_request(branch['name'])
end

Loading…
Cancel
Save