From c75953d34319ed8ce162a03d1fe502d5442e873b Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 14 Dec 2023 16:45:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=88=86=E6=94=AF=E5=B7=B2=E5=AD=98=E5=9C=A8=E5=88=86=E6=94=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/gitea/repository/entries/create_service.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/services/gitea/repository/entries/create_service.rb b/app/services/gitea/repository/entries/create_service.rb index ac27b3afb..406106744 100644 --- a/app/services/gitea/repository/entries/create_service.rb +++ b/app/services/gitea/repository/entries/create_service.rb @@ -59,7 +59,11 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService 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}文件已存在,不能重复创建!") + if json_parse!(body)["message"].present? && json_parse!(body)["message"].starts_with?("branch already exists") + error("#{@body[:new_branch]}分支已存在!") + else + error("#{filepath}文件已存在,不能重复创建!") + end end else Rails.logger.error("Gitea api url==#{url},status:#{status},body=#{body}")