From a23a4dd2705ddf5b13ccea938d703765cb14ce78 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 4 Nov 2025 17:34:08 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E7=9A=84=E6=96=B0=E6=96=87=E4=BB=B6=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=97=B6=EF=BC=8C=E7=9B=B4=E6=8E=A5=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=96=B0=E6=96=87=E4=BB=B6new=5Ffile=5Fsha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 9b2bedd06..da9e29e7b 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -80,7 +80,12 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController tip_exception("已经存在#{params[:pipeline_name]}流水线!") if has_pipeline.present? if @pipeline.yaml.present? sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) - if sha.present? + new_file_sha = get_pipeline_file_sha(params[:pipeline_name], @pipeline.branch) + # 重命名的新文件存在时,直接修改新文件new_file_sha + if sha.present? && new_file_sha.present? + interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update", params[:pipeline_name]).merge(sha: new_file_sha, from_path: ".gitea/workflows/#{@pipeline.pipeline_name}.yml")) + tip_exception(interactor.error) unless interactor.success? + else interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update", params[:pipeline_name]).merge(sha: sha, from_path: ".gitea/workflows/#{@pipeline.pipeline_name}.yml")) tip_exception(interactor.error) unless interactor.success? end