From 40dfc7d490ed6d8b0b1123af9152fe4b9622c09a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 23 Oct 2019 17:27:15 +0800 Subject: [PATCH] =?UTF-8?q?python=E6=96=87=E4=BB=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 4e587513a..4b2e3f54f 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -264,11 +264,13 @@ class MyshixunsController < ApplicationController unless @hide_code || (@myshixun.shixun&.vnc_evaluate && params[:evaluate].present?) # 远程版本库文件内容 last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] - content = if @myshixun.mirror_name.select {|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present? - params[:content].gsub(/\t/, ' ').gsub(/ /, ' ') # 这个不是空格,在windows机器上带来的问题 - else - params[:content] - end + + content = + if python_file?(path) + params[:content].gsub(/\t/, ' ').gsub(/ /, ' ') + else + params[:content] + end uid_logger_dubug("###11222333####{content}") uid_logger_dubug("###222333####{last_content}") @@ -374,4 +376,9 @@ class MyshixunsController < ApplicationController @repo_path = @myshixun.try(:repo_path) @path = params[:path] end + + def python_file?(path) + false if path.blank? + path.to_s.split(".").last.downcase == "py" + end end