forked from Trustie/forgeplus
fixed 重命名的新文件存在时,直接修改新文件new_file_sha, 同时删除老文件
This commit is contained in:
parent
a0c8207986
commit
df032c5343
|
|
@ -81,11 +81,13 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
|||
if @pipeline.yaml.present?
|
||||
sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch)
|
||||
new_file_sha = get_pipeline_file_sha(".gitea/workflows/#{params[:pipeline_name]}.yml", @pipeline.branch)
|
||||
# 重命名的新文件存在时,直接修改新文件new_file_sha
|
||||
# 重命名的新文件存在时,直接修改新文件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"))
|
||||
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/#{params[:pipeline_name]}.yml"))
|
||||
tip_exception(interactor.error) unless interactor.success?
|
||||
else
|
||||
del_interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params(sha).merge(identifier: @project.identifier))
|
||||
tip_exception(del_interactor.error) unless del_interactor.success?
|
||||
elsif sha.present? && new_file_sha.blank?
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue