change entries error

This commit is contained in:
sylor_huang@126.com 2020-06-30 11:39:31 +08:00
parent ef3a95ba39
commit 09ee934ac1
2 changed files with 3 additions and 4 deletions

View File

@ -28,7 +28,7 @@ class RepositoriesController < ApplicationController
@project.increment!(:visits) @project.increment!(:visits)
@project_owner = @project.owner @project_owner = @project.owner
@entries = Gitea::Repository::Entries::ListService.new(@project_owner, @project.identifier, ref: @ref).call @entries = Gitea::Repository::Entries::ListService.new(@project_owner, @project.identifier, ref: @ref).call
@entries = @entries.sort_by{ |hash| hash['type'] } if @entries.present? @entries = @entries["status"].to_i == 1 ? @entries.sort_by{ |hash| hash['type'] } : []
@path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/" @path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/"
end end

View File

@ -24,12 +24,11 @@ class Gitea::Repository::Entries::ListService < Gitea::ClientService
end end
def render_result(response) def render_result(response)
body = JSON.parse(response.body)
case response.status case response.status
when 200 when 200
body JSON.parse(response.body).merge({"status": 1})
else else
{status: -1, message: "#{body['message']}"} {'status': -1, 'message': "#{body['message']}"}
end end
end end
end end