From c87da2947f312a985a3e51879ce48395a35972fb Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 28 May 2024 18:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=94=E8=B0=83=E5=9B=BE=E5=BD=A2=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=8C=96-=E8=BF=94=E5=9B=9E=E6=96=87=E4=BB=B6sha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index e8a7a1c3b..c1bcc8299 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -36,7 +36,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update").merge(sha: sha)) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("create")) tip_exception(interactor.error) unless interactor.success? file = interactor.result - render_ok({ pipeline_yaml: pipeline_yaml, pipeline_name: params[:pipeline_name], file_name: @pipeline.file_name, sha: file['content']['sha'] }) + render_ok({ pipeline_yaml: pipeline_yaml, pipeline_name: params[:pipeline_name], file_name: @pipeline.file_name, sha: sha.present? ? sha : file['content']['sha'] }) end def build_yaml @@ -82,7 +82,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController end def build_pipeline_yaml(pipeline_name, pipeline_json) - if pipeline_json.present? + if pipeline_json.present? && pipeline_json.present? @pipeline_name = pipeline_name params_nodes = pipeline_json["nodes"].select { |node| !["on-push", "on-schedule"].include?(node["name"]) } on_nodes = pipeline_json["nodes"].select { |node| ["on-push", "on-schedule"].include?(node["name"]) }