FIX sub entries api return hash object when entries is file
This commit is contained in:
parent
0ca699cc49
commit
7449351270
|
@ -61,13 +61,10 @@ class RepositoriesController < ApplicationController
|
|||
@sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri})
|
||||
end
|
||||
else
|
||||
interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: @ref)
|
||||
interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, file_path_uri, ref: @ref)
|
||||
if interactor.success?
|
||||
result = interactor.result
|
||||
return @sub_entries = [] if result.is_a?(Hash) && result[:status] == -1
|
||||
|
||||
@sub_entries = result.is_a?(Array) ? result : [result]
|
||||
@sub_entries = @sub_entries.sort_by{ |hash| hash['type'] }
|
||||
@sub_entries = result.is_a?(Array) ? result.sort_by{ |hash| hash['type'] } : result
|
||||
else
|
||||
render_error(interactor.error)
|
||||
end
|
||||
|
|
|
@ -31,8 +31,10 @@ class Gitea::Repository::Entries::GetService < Gitea::ClientService
|
|||
case response.status
|
||||
when 200
|
||||
body
|
||||
when 404
|
||||
raise '你访问的文件不存在'
|
||||
else
|
||||
{status: -1, message: "#{body['message']}"}
|
||||
raise body['message']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,12 +6,11 @@ if @project.forge?
|
|||
json.nil!
|
||||
end
|
||||
end
|
||||
#json.tags_count @tags_count
|
||||
#json.branches_count @branches_count
|
||||
#json.commits_count @commits_count
|
||||
json.entries do
|
||||
json.array! @sub_entries do |entry|
|
||||
json.partial! 'repositories/simple_entry', locals: { entry: entry }
|
||||
if @sub_entries.is_a?(Array)
|
||||
json.partial! 'repositories/simple_entry', collection: @sub_entries, as: :entry
|
||||
elsif @sub_entries.is_a?(Hash)
|
||||
json.partial! 'repositories/simple_entry', locals: { entry: @sub_entries }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue