From 33e17e84392c2dbd2a6fde08d69b53f85edb675a Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 18:18:19 +0800 Subject: [PATCH] fix: educoder sub_entries and commit author --- app/controllers/repositories_controller.rb | 12 ++++++++++++ app/views/repositories/_commit.json.jbuilder | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0292dc1d1..f3fffd6e1 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -81,6 +81,18 @@ class RepositoriesController < ApplicationController } else @sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri}) + if @sub_entries.blank? + @sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri) + return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1 + tmp_entries = [{ + "content" => @sub_entries['data']['content'], + "type" => "blob" + }] + @sub_entries = { + "trees"=>tmp_entries, + "commits" => [{}] + } + end end else @path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/" diff --git a/app/views/repositories/_commit.json.jbuilder b/app/views/repositories/_commit.json.jbuilder index 9c29116e9..e860b01fa 100644 --- a/app/views/repositories/_commit.json.jbuilder +++ b/app/views/repositories/_commit.json.jbuilder @@ -7,11 +7,20 @@ if @project.educoder? json.timestamp 0 json.time_from_now commit[0]['time'] end - json.author do - {} - # json.partial! '/projects/author', user: render_commit_author(commit['author']) + json.author do + json.id nil + json.login commit[0]['author']['username'] + json.name commit[0]['author']['username'] + json.type nil + json.image_url commit[0]['author']['image_url'] + end + json.commiter do + json.id nil + json.login commit[0]['author']['username'] + json.name commit[0]['author']['username'] + json.type nil + json.image_url commit[0]['author']['image_url'] end - json.committer {} end if @project.forge?