FIX get latest commit bug

This commit is contained in:
Jasder 2021-01-20 14:25:07 +08:00
parent f3d4f437cb
commit b7e23a62d0
3 changed files with 18 additions and 17 deletions

View File

@ -1,7 +1,9 @@
json.commit do
json.message entry['latest_commit']['message']
json.sha entry['latest_commit']['sha']
json.created_at render_format_time_with_unix(entry['latest_commit']['created_at'].to_i)
json.time_from_now time_from_now(render_format_time_with_unix(entry['latest_commit']['created_at'].to_i))
json.created_at_unix entry['latest_commit']['created_at']
if latest_commit.blank?
json.nil!
else
json.message latest_commit['message']
json.sha latest_commit['sha']
json.created_at render_format_time_with_unix(latest_commit['created_at'].to_i)
json.time_from_now time_from_now(render_format_time_with_unix(latest_commit['created_at'].to_i))
json.created_at_unix latest_commit['created_at']
end

View File

@ -15,12 +15,8 @@ if @project.forge?
json.direct_download direct_download
json.image_type image_type
json.is_readme_file is_readme?(entry['type'], entry['name'])
if entry['latest_commit']
if entry['type'] != 'file'
json.partial! 'last_commit', entry: entry
else
json.commit nil
end
json.commit do
json.partial! 'last_commit', latest_commit: entry['latest_commit']
end
end
@ -38,8 +34,11 @@ if @project.educoder?
json.direct_download false
json.image_type false
json.is_readme_file false
if entry['latest_commit']
# json.partial! 'last_commit', entry: entry
json.partial! 'repositories/simple_entry', locals: { entry: entry }
json.commit do
json.message entry['title']
json.time_from_now entry['time']
json.sha nil
json.created_at_unix nil
json.created_at nil
end
end

View File

@ -54,8 +54,8 @@ if @project.forge?
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
json.commit do
json.partial! 'last_commit', latest_commit: entry['latest_commit']
end
end
end