Merge branches 'dev_item_bank' and 'dev_jupyter' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_jupyter

dev_jupyter
杨树明 5 years ago
commit 3e4ef82c62

@ -53,13 +53,17 @@ module GitHelper
end end
# 添加目录 # 添加目录
def git_add_folder(folder_path, author_name, author_email, message) def git_add_folder(repo_path, tree_path, author_name, author_email, message)
GitService.add_tree(file_path: folder_path, message: message, author_name: author_name, author_email: author_email) Rails.logger.info("#####repo_path:#{repo_path}, tree_path: #{tree_path}")
GitService.add_tree(repo_path: repo_path, tree_path: tree_path, message: message, author_name: author_name,
author_email: author_email)
end end
# 删除文件 # 删除文件
def git_delete_file(file_path, author_name, author_email, message) def git_delete_file(repo_path, tree_path, author_name, author_email, message)
GitService.delete_file(file_path: file_path, message: message, author_name: author_name, author_email: author_email) Rails.logger.info("#####repo_path:#{repo_path}, tree_path: #{tree_path}")
GitService.delete_file(repo_path: repo_path, tree_path: tree_path, message: message, author_name: author_name,
author_email: author_email)
end end
# 版本库Fork功能 # 版本库Fork功能

@ -16,7 +16,7 @@ class ShixunsController < ApplicationController
:propaedeutics, :departments, :apply_shixun_mirror, :jupyter_exec, :propaedeutics, :departments, :apply_shixun_mirror, :jupyter_exec,
:get_mirror_script, :download_file, :shixun_list, :batch_send_to_course] :get_mirror_script, :download_file, :shixun_list, :batch_send_to_course]
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy,
:add_file, :jupyter_exec] :add_file, :jupyter_exec, :upload_git_file, :delete_git_file, :upload_git_folder]
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, :apply_public, :upload_git_folder, before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, :apply_public, :upload_git_folder,
:shixun_members_added, :change_manager, :collaborators_delete, :upload_git_file, :shixun_members_added, :change_manager, :collaborators_delete, :upload_git_file,
@ -896,7 +896,8 @@ class ShixunsController < ApplicationController
author_email = current_user.git_mail author_email = current_user.git_mail
message = params[:message] || "upload file by browser" message = params[:message] || "upload file by browser"
uid_logger("-----author_email: #{author_email}") uid_logger("-----author_email: #{author_email}")
update_file_base64_content(content, @repo_path, @path, author_email, author_name, message) path = @path.present? ? "#{@path}/#{upload_file.original_filename}" : "#{upload_file.original_filename}"
update_file_base64_content(content, @repo_path, path, author_email, author_name, message)
render_ok render_ok
end end
@ -905,7 +906,7 @@ class ShixunsController < ApplicationController
author_name = current_user.real_name author_name = current_user.real_name
author_email = current_user.git_mail author_email = current_user.git_mail
message = params[:message] || "upload folder by browser" message = params[:message] || "upload folder by browser"
git_add_folder(@path, author_name, author_email, message) git_add_folder(@repo_path, @path, author_name, author_email, message)
render_ok render_ok
end end
@ -913,7 +914,7 @@ class ShixunsController < ApplicationController
author_name = current_user.real_name author_name = current_user.real_name
author_email = current_user.git_mail author_email = current_user.git_mail
message = params[:message] || "delete file by browser" message = params[:message] || "delete file by browser"
git_delete_file(@path, author_name, author_email, message) git_delete_file(@repo_path, @path, author_name, author_email, message)
render_ok render_ok
end end
@ -1095,9 +1096,8 @@ private
@repo_path = if params[:secret_repository] @repo_path = if params[:secret_repository]
@shixun.shixun_secret_repository&.repo_path @shixun.shixun_secret_repository&.repo_path
else else
@shixun.try(:repo_path) @shixun.repo_path
end end
logger.info("######{@repo_path}")
@path = params[:path] @path = params[:path]
end end

@ -68,8 +68,8 @@ class GitService
content = JSON.parse(body) content = JSON.parse(body)
if content["code"] != 0 if content["code"] != 0
raise("版本库异常")
logger.error("repository error: #{content['msg']}") logger.error("repository error: #{content['msg']}")
raise("版本库异常")
end end
#raise content["msg"] if content["code"] != 0 #raise content["msg"] if content["code"] != 0

Loading…
Cancel
Save