From e0c47c2abdd707a315b0c2842c2ce2fc19ede353 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Dec 2021 16:18:13 +0800 Subject: [PATCH] fix: educoder clone url --- app/controllers/repositories_controller.rb | 2 +- app/views/repositories/commits.json.jbuilder | 24 ++++++++++++++++++-- app/views/repositories/detail.json.jbuilder | 2 +- app/views/repositories/entries.json.jbuilder | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 3f797a13a..0292dc1d1 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -96,7 +96,7 @@ class RepositoriesController < ApplicationController def commits if @project.educoder? - @hash_commit = nil + @commits = Educoder::Repository::Commits::ListService.call(@project&.project_educoder&.repo_name) else if params[:filepath].present? file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip)) diff --git a/app/views/repositories/commits.json.jbuilder b/app/views/repositories/commits.json.jbuilder index 33406e6a5..11644f832 100644 --- a/app/views/repositories/commits.json.jbuilder +++ b/app/views/repositories/commits.json.jbuilder @@ -1,6 +1,26 @@ -if @hash_commit.blank? #如果有状态值,则表示报错了 +if @hash_commit.blank? || @project.educoder? #如果有状态值,则表示报错了 json.total_count 0 - json.commits [] + json.commits do + json.array! @commits do |commit| + json.sha commit['id'] + json.message commit['title'] + json.time_from_now commit['time'] + json.author do + json.id nil + json.login commit['author']['username'] + json.name commit['author']['username'] + json.type nil + json.image_url commit['author']['image_url'] + end + json.commiter do + json.id nil + json.login commit['author']['username'] + json.name commit['author']['username'] + json.type nil + json.image_url commit['author']['image_url'] + end + end + end else json.total_count @hash_commit[:total_count] json.commits do diff --git a/app/views/repositories/detail.json.jbuilder b/app/views/repositories/detail.json.jbuilder index 14db8b092..9381c4737 100644 --- a/app/views/repositories/detail.json.jbuilder +++ b/app/views/repositories/detail.json.jbuilder @@ -44,7 +44,7 @@ end if @result[:repo] json.size replace_bytes_to_b(number_to_human_size(@result[:repo]['size'].to_i*1024)) json.ssh_url @result[:repo]['ssh_url'] - json.clone_url @result[:repo]['clone_url'] + json.clone_url @project.educoder? ? "#{Rails.application.config_for(:configuration)['educoder']['git_site']}/#{@project&.project_educoder&.repo_name}.git" : @result[:repo]['clone_url'] json.default_branch @project.educoder? ? "master" : @result[:repo]['default_branch'] json.empty @result[:repo]['empty'] json.full_name @result[:repo]['full_name'] diff --git a/app/views/repositories/entries.json.jbuilder b/app/views/repositories/entries.json.jbuilder index 8d1e67beb..6dea93b32 100644 --- a/app/views/repositories/entries.json.jbuilder +++ b/app/views/repositories/entries.json.jbuilder @@ -7,7 +7,7 @@ if @project.educoder? end end json.commits_count @entries['commit_count'] - json.zip_url @entries['git_url'] + json.zip_url '' json.tar_url '' json.entries do json.array! @entries['trees'] do |entry|