Browse Source

FIX code review

tags/v1.0.0
Jasder 5 years ago
parent
commit
b5d3f32d68
3 changed files with 4 additions and 22 deletions
  1. +2
    -1
      app/services/gitea/client_service.rb
  2. +1
    -10
      app/services/gitea/repository/commits/compare_service.rb
  3. +1
    -11
      app/services/gitea/repository/commits/get_service.rb

+ 2
- 1
app/services/gitea/client_service.rb View File

@@ -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 = "请求失败"


+ 1
- 10
app/services/gitea/repository/commits/compare_service.rb View File

@@ -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

+ 1
- 11
app/services/gitea/repository/commits/get_service.rb View File

@@ -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

Loading…
Cancel
Save