FIX get readme file bug

(cherry picked from commit 30138cc1fa)
This commit is contained in:
Jasder
2021-01-15 18:36:19 +08:00
committed by moshenglv
parent 6fa4ee6c14
commit 06a7cb7558
3 changed files with 19 additions and 16 deletions

View File

@@ -8,12 +8,13 @@ if @project.forge?
json.path entry['path']
json.type entry['type']
json.size entry['size']
json.content entry['content'].present? && !direct_download ? render_decode64_content(entry['content']) : ""
json.content decode64_content(entry, @owner, @repository, @ref)
json.target entry['target']
json.download_url entry['download_url']
json.direct_download direct_download
json.image_type image_type
json.is_readme_file is_readme_type?(file_name)
json.is_readme_file is_readme?(entry['type'], entry['name'])
if entry['latest_commit']
if entry['type'] != 'file'
json.partial! 'last_commit', entry: entry

View File

@@ -51,17 +51,8 @@ if @project.forge?
json.sha entry['sha']
json.type entry['type']
json.size entry['size']
content =
if is_readme_type?(entry['name'])
is_readme_file = true
content = Gitea::Repository::Entries::GetService.call(@owner, @project.identifier, entry['name'], ref: @ref)['content']
readme_render_decode64_content(content, @path)
else
is_readme_file = false
entry['content']
end
json.is_readme_file is_readme_file
json.content content
json.is_readme_file is_readme?(entry['type'], entry['name'])
json.content decode64_content(entry, @owner, @repository, @ref, @path)
json.target entry['target']
if entry['latest_commit']
json.partial! 'last_commit', entry: entry