fixed 流水线删除报错,判断文件不存在
This commit is contained in:
parent
a06e55d30c
commit
b67ed4d74b
|
@ -139,8 +139,11 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||||
def destroy
|
def destroy
|
||||||
@pipeline = Action::Pipeline.find(params[:id])
|
@pipeline = Action::Pipeline.find(params[:id])
|
||||||
if @pipeline
|
if @pipeline
|
||||||
interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params.merge(identifier: @project.identifier))
|
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?
|
tip_exception(interactor.error) unless interactor.success?
|
||||||
|
end
|
||||||
@pipeline.destroy!
|
@pipeline.destroy!
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
|
@ -230,12 +233,12 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def del_content_params
|
def del_content_params(sha)
|
||||||
{
|
{
|
||||||
filepath: ".gitea/workflows/#{@pipeline.pipeline_name}.yml",
|
filepath: ".gitea/workflows/#{@pipeline.pipeline_name}.yml",
|
||||||
base64_filepath: Base64.encode64(".gitea/workflows/#{@pipeline.pipeline_name}.yml").gsub(/\n/, ''),
|
base64_filepath: Base64.encode64(".gitea/workflows/#{@pipeline.pipeline_name}.yml").gsub(/\n/, ''),
|
||||||
branch: @pipeline.branch,
|
branch: @pipeline.branch,
|
||||||
sha: get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch)
|
sha: sha
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue