From a4c2242a8a721b663c9ef888332024ce224cab83 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 14 Nov 2024 16:09:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Acompare=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=96=B0=E5=A2=9Efilescount=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/compare_controller.rb | 3 ++- app/views/compare/show.json.jbuilder | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/compare_controller.rb b/app/controllers/compare_controller.rb index afdceac9d..a007b1178 100644 --- a/app/controllers/compare_controller.rb +++ b/app/controllers/compare_controller.rb @@ -18,6 +18,7 @@ class CompareController < ApplicationController @page_limit = page_limit <=0 ? 15 : page_limit @page_offset = (@page_size -1) * @page_limit Rails.logger.info("+========#{@page_size}-#{@page_limit}-#{@page_offset}") + Rails.logger.info @compare_result end private @@ -36,7 +37,7 @@ class CompareController < ApplicationController if @exist_pullrequest.present? return -2, "在这些分支之间的合并请求已存在:#{@exist_pullrequest.try(:title)}" else - if @compare_result["Commits"].blank? && @compare_result["Diff"].blank? + if @compare_result["FilesCount"].to_i == 0 && @compare_result["CommitsCount"].to_i == 0 return -2, "分支内容相同,无需创建合并请求" end end diff --git a/app/views/compare/show.json.jbuilder b/app/views/compare/show.json.jbuilder index 135537cda..9ed8cd5b3 100644 --- a/app/views/compare/show.json.jbuilder +++ b/app/views/compare/show.json.jbuilder @@ -1,4 +1,5 @@ json.commits_count @compare_result['CommitsCount'] +json.files_count @compare_result['FilesCount'] # json.commits @compare_result['Commits'], partial: 'pull_requests/commit', as: :commit json.commits do if @compare_result['Commits'].present?