forgeplus/app/controllers/concerns/api/pull_helper.rb

19 lines
585 B
Ruby
Raw Normal View History

2022-07-25 16:21:03 +08:00
module Api::PullHelper
extend ActiveSupport::Concern
def load_pull_request
pull_request_id = params[:pull_id] || params[:id]
2024-11-18 15:23:57 +08:00
@pull_request = @project.pull_requests.where(gitea_number: pull_request_id).where.not(id: pull_request_id).take || @project.pull_requests.find_by_id(pull_request_id)
2022-07-25 16:21:03 +08:00
@issue = @pull_request&.issue
if @pull_request
logger.info "###########pull_request founded"
@pull_request
else
logger.info "###########pull_request not found"
@pull_request = nil
render_not_found and return
end
@pull_request
end
end