fixed 流水线删除报错,判断文件不存在

This commit is contained in:
xxq250 2025-03-19 17:23:48 +08:00
parent a06e55d30c
commit b67ed4d74b
1 changed files with 7 additions and 4 deletions

View File

@ -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