mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-10 06:49:49 +08:00
FIX code review
This commit is contained in:
@@ -131,7 +131,6 @@ class Gitea::ClientService < ApplicationService
|
||||
{status: 200}
|
||||
end
|
||||
when 401
|
||||
""
|
||||
raise Error, mark + "401"
|
||||
when 422
|
||||
result = JSON.parse(response&.body)
|
||||
@@ -147,6 +146,8 @@ class Gitea::ClientService < ApplicationService
|
||||
raise Error, mark + message
|
||||
when 403
|
||||
{status: 403, message: '你没有权限操作!'}
|
||||
when 404
|
||||
{status: 404, message: '你访问的链接不存在!'}
|
||||
else
|
||||
if response&.body.blank?
|
||||
message = "请求失败"
|
||||
|
||||
@@ -15,7 +15,7 @@ class Gitea::Repository::Commits::CompareService < Gitea::ClientService
|
||||
|
||||
def call
|
||||
response = get(url, params)
|
||||
render_result(response)
|
||||
render_status(response)
|
||||
end
|
||||
|
||||
private
|
||||
@@ -26,13 +26,4 @@ class Gitea::Repository::Commits::CompareService < Gitea::ClientService
|
||||
def url
|
||||
"/repos/#{owner}/#{repo}/compare/#{base}...#{head}".freeze
|
||||
end
|
||||
|
||||
def render_result(response)
|
||||
case response.status
|
||||
when 200
|
||||
JSON.parse(response.body)
|
||||
else
|
||||
{status: -1, message: "#{body['message']}"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class Gitea::Repository::Commits::GetService < Gitea::ClientService
|
||||
|
||||
def call
|
||||
response = get(url, params)
|
||||
render_result(response)
|
||||
render_status(response)
|
||||
end
|
||||
|
||||
private
|
||||
@@ -32,14 +32,4 @@ class Gitea::Repository::Commits::GetService < Gitea::ClientService
|
||||
"/repos/#{owner}/#{repo}/git/commits/#{sha}".freeze
|
||||
end
|
||||
end
|
||||
|
||||
def render_result(response)
|
||||
body = JSON.parse(response.body)
|
||||
case response.status
|
||||
when 200
|
||||
JSON.parse(response.body)
|
||||
else
|
||||
{status: -1, message: "#{body['message']}"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user