更改:优化commit详情接口
This commit is contained in:
parent
96a70007fd
commit
49e2b35a1e
|
@ -151,7 +151,7 @@ class RepositoriesController < ApplicationController
|
||||||
return render_error('暂未开放,敬请期待.')
|
return render_error('暂未开放,敬请期待.')
|
||||||
else
|
else
|
||||||
@commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, @owner&.gitea_token)
|
@commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, @owner&.gitea_token)
|
||||||
@commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, @owner&.gitea_token, {diff: true})
|
# @commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, @owner&.gitea_token, {diff: true})
|
||||||
render_error(@commit[:message], @commit[:status]) if @commit.has_key?(:status) || @commit_diff.has_key?(:status)
|
render_error(@commit[:message], @commit[:status]) if @commit.has_key?(:status) || @commit_diff.has_key?(:status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Gitea::Repository::Commits::ListService < Gitea::ClientService
|
||||||
|
|
||||||
private
|
private
|
||||||
def params
|
def params
|
||||||
{ sha: args[:sha] || 'master', page: args[:page] || PAGINATE_DEFAULT_PAGE, limit: args[:limit] || PAGINATE_DEFAULT_LIMIT, token: args[:token] || "", stat: args[:page].to_i != 1 && args[:limit] !=1 }
|
{ sha: args[:sha] || 'master', page: args[:page] || PAGINATE_DEFAULT_PAGE, limit: args[:limit] || PAGINATE_DEFAULT_LIMIT, token: args[:token] || "", stat: args[:page].to_i != 1 && args[:limit] !=1, files: false }
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
|
|
|
@ -3,10 +3,10 @@ if @commit.blank? #如果有状态值,则表示报错了
|
||||||
json.total_count 0
|
json.total_count 0
|
||||||
json.commits []
|
json.commits []
|
||||||
else
|
else
|
||||||
json.files_count @commit_diff['NumFiles']
|
# json.files_count @commit_diff['NumFiles']
|
||||||
json.total_addition @commit_diff['TotalAddition']
|
# json.total_addition @commit_diff['TotalAddition']
|
||||||
json.total_deletion @commit_diff['TotalDeletion']
|
# json.total_deletion @commit_diff['TotalDeletion']
|
||||||
json.files @commit_diff['Files'], partial: 'pull_requests/diff_file', as: :file, locals: {sha: @sha}
|
# json.files @commit_diff['Files'], partial: 'pull_requests/diff_file', as: :file, locals: {sha: @sha}
|
||||||
|
|
||||||
json.partial! 'commit', commit: @commit, project: @project
|
json.partial! 'commit', commit: @commit, project: @project
|
||||||
json.parents @commit['parents'] do |parent|
|
json.parents @commit['parents'] do |parent|
|
||||||
|
|
Loading…
Reference in New Issue