diff --git a/app/controllers/statistic_controller.rb b/app/controllers/statistic_controller.rb index 6eaa5bc99..40540e5e5 100644 --- a/app/controllers/statistic_controller.rb +++ b/app/controllers/statistic_controller.rb @@ -2,24 +2,24 @@ class StatisticController < ApplicationController # 平台概况 def platform_profile - @platform_user_query = Statistic::PlatformUserQuery.new(params).call - @platform_project_query = Statistic::PlatformProjectQuery.new(params).call - @platform_course_query = Statistic::PlatformCourseQuery.new(params).call + @platform_user_query = Statistic::PlatformUserQuery.new(params).call rescue [0, 0, 0] + @platform_project_query = Statistic::PlatformProjectQuery.new(params).call rescue [0, 0, 0] + @platform_course_query = Statistic::PlatformCourseQuery.new(params).call rescue [0, 0, 0] end # 平台代码提交数据 def platform_code - @platform_pull_request_query = Statistic::PlatformPullRequestQuery.new(params).call - @platform_commit_query = Statistic::PlatformCommitQuery.new(params,current_user).call + @platform_pull_request_query = Statistic::PlatformPullRequestQuery.new(params).call rescue [0, 0] + @platform_commit_query = Statistic::PlatformCommitQuery.new(params,current_user).call rescue [0, 0] end # 项目案例活跃度排行榜 def active_project_rank - @active_project_rank_query = Statistic::ActiveProjectRankQuery.new(params, current_user).call + @active_project_rank_query = Statistic::ActiveProjectRankQuery.new(params, current_user).call rescue [] end # 开发者活跃度排行榜 def active_developer_rank - @active_developer_rank_query = Statistic::ActiveDeveloperRankQuery.new(params, current_user).call + @active_developer_rank_query = Statistic::ActiveDeveloperRankQuery.new(params, current_user).call rescue [] end end \ No newline at end of file diff --git a/app/interactors/gitea/create_file_interactor.rb b/app/interactors/gitea/create_file_interactor.rb index 389813520..cf753767c 100644 --- a/app/interactors/gitea/create_file_interactor.rb +++ b/app/interactors/gitea/create_file_interactor.rb @@ -62,7 +62,7 @@ module Gitea file_params = {} file_params = file_params.merge(branch: @params[:branch]) unless @params[:branch].blank? file_params = file_params.merge(new_branch: @params[:new_branch]) unless @params[:new_branch].blank? - file_params = file_params.merge(content: Base64.encode64(@params[:content] || "")) + file_params = file_params.merge(content: @params[:content] || "") file_params = file_params.merge(message: @params[:message]) unless @params[:message].blank? file_params = file_params.merge(committer: @params[:committer]) file_params diff --git a/app/services/gitea/repository/entries/create_service.rb b/app/services/gitea/repository/entries/create_service.rb index 1bdc7246d..14b373335 100644 --- a/app/services/gitea/repository/entries/create_service.rb +++ b/app/services/gitea/repository/entries/create_service.rb @@ -56,7 +56,7 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService when 403 then error("你没有权限操作!") when 404 then error("你操作的链接不存在!") when 422 - if @body[:new_branch].include?('/') || @body[:new_branch].include?('\'') || @body[:new_branch].include?('^') || @body[:new_branch].include?('*') + if @body[:new_branch].present? && (@body[:new_branch].include?('/') || @body[:new_branch].include?('\'') || @body[:new_branch].include?('^') || @body[:new_branch].include?('*')) error("不合法的分支名称!") else error("#{filepath}文件已存在,不能重复创建!")