parent
b6aa0fd76c
commit
5667c0854c
|
@ -6,10 +6,26 @@ class CompareController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
compare
|
||||
end
|
||||
|
||||
private
|
||||
def compare
|
||||
base, head = compare_params
|
||||
|
||||
# TODO: 处理fork的项目向源项目发送PR的base、head参数问题
|
||||
@compare_result ||=
|
||||
head.include?(":") ? gitea_compare(base, head) : gitea_compare(head, base)
|
||||
end
|
||||
|
||||
def compare_params
|
||||
base = Addressable::URI.unescape(params[:base])
|
||||
head = params[:head].include?('json') ? params[:head]&.split('.json')[0] : params[:head]
|
||||
@compare_result = Gitea::Repository::Commits::CompareService.call(@owner.login, @project.identifier, head, base)
|
||||
|
||||
# render json: @compare_result
|
||||
[base, head]
|
||||
end
|
||||
|
||||
def gitea_compare(base, head)
|
||||
Gitea::Repository::Commits::CompareService.call(@owner.login, @project.identifier, base, head)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
json.partial! "commons/success"
|
||||
json.project_name @project.name
|
||||
json.identifier @project.identifier
|
||||
json.pr_time time_from_now(@pull_request.updated_at)
|
||||
json.commits_count @pull_request.commits_count
|
||||
json.files_count @pull_request.files_count
|
||||
|
|
Loading…
Reference in New Issue