From b67ed4d74bfe64d857d4de785f1ec3bff2dcfa97 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 19 Mar 2025 17:23:48 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E6=B5=81=E6=B0=B4=E7=BA=BF=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8A=A5=E9=94=99,=E5=88=A4=E6=96=AD=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/projects/pipelines_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 107bd357c..5aa62caab 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -139,8 +139,11 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController def destroy @pipeline = Action::Pipeline.find(params[:id]) if @pipeline - interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params.merge(identifier: @project.identifier)) - tip_exception(interactor.error) unless interactor.success? + sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) + if sha.present? + interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params(sha).merge(identifier: @project.identifier)) + tip_exception(interactor.error) unless interactor.success? + end @pipeline.destroy! end render_ok @@ -230,12 +233,12 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController } end - def del_content_params + def del_content_params(sha) { filepath: ".gitea/workflows/#{@pipeline.pipeline_name}.yml", base64_filepath: Base64.encode64(".gitea/workflows/#{@pipeline.pipeline_name}.yml").gsub(/\n/, ''), branch: @pipeline.branch, - sha: get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) + sha: sha } end