From b3d78741a3dca55e8ca3228bd2568b22af9d506d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Thu, 28 Jul 2022 09:31:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fixed=20reposyncer=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0gitlink?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ob_repository_syncs_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/ob_repository_syncs_controller.rb b/app/controllers/ob_repository_syncs_controller.rb index 0f1c64b1b..107320934 100644 --- a/app/controllers/ob_repository_syncs_controller.rb +++ b/app/controllers/ob_repository_syncs_controller.rb @@ -13,8 +13,8 @@ class ObRepositorySyncsController < ApplicationController tip_exception "参数错误" if params[:github_address].blank? && params[:gitee_address].blank? project_name ="#{@project.owner.name}:#{@project.identifier}" service = ObRepositorySync::ApiService.new(project_name) - params = params.merge({ "gitlink_address": @project.repository.url }) - res = service.create_projects(params) + project_params = params.merge({ "gitlink_address": @project.repository.url }) + res = service.create_projects(project_params) tip_exception "保存失败: #{res["msg"]}" if res["code"].to_s != "200" sync_id = res["data"]["id"] ob_repository_sync = ObRepositorySync.find_or_initialize_by(project_id: @project.id) From 6e54203ebb5d2e81edd9a308726dbe9e14899ca3 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 28 Jul 2022 13:56:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=8F=90=E4=BA=A4=E6=96=87=E4=BB=B6=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1=E4=BB=A5=E5=8F=8A=E6=95=B0=E6=8D=AE=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/contents/batch_create_service.rb | 3 ++- .../v1/projects/contents/batch.json.jbuilder | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/services/api/v1/projects/contents/batch_create_service.rb b/app/services/api/v1/projects/contents/batch_create_service.rb index d987f9318..ec4aec8d1 100644 --- a/app/services/api/v1/projects/contents/batch_create_service.rb +++ b/app/services/api/v1/projects/contents/batch_create_service.rb @@ -13,7 +13,6 @@ class Api::V1::Projects::Contents::BatchCreateService < ApplicationService def initialize(project, params, token=nil) - puts params @project = project @owner = project&.owner.login @repo = project&.identifier @@ -63,6 +62,7 @@ class Api::V1::Projects::Contents::BatchCreateService < ApplicationService committer: Time.at(committer_timeunix.to_i) }, message: message, + branch: branch, new_branch: new_branch, signoff: false } @@ -77,6 +77,7 @@ class Api::V1::Projects::Contents::BatchCreateService < ApplicationService end def excute_data_to_gitea + puts request_body.to_json @gitea_data = $gitea_client.post_repos_contents_batch_by_owner_repo(owner, repo, {body: request_body.to_json, query: request_params}) rescue nil raise Error, '创建文件失败!' unless @gitea_data.is_a?(Hash) end diff --git a/app/views/api/v1/projects/contents/batch.json.jbuilder b/app/views/api/v1/projects/contents/batch.json.jbuilder index a9ef08fa6..fa41bfb9a 100644 --- a/app/views/api/v1/projects/contents/batch.json.jbuilder +++ b/app/views/api/v1/projects/contents/batch.json.jbuilder @@ -3,12 +3,16 @@ json.commit do json.authored_time render_unix_time(@result_object['commit']['author']['date']) json.commited_time render_unix_time(@result_object['commit']['committer']['date']) end -json.contents @result_object['contents'].each do |content| - json.name content['name'] - json.path content['path'] - json.sha content['sha'] - json.type content['type'] - json.size content['size'] - json.encoding content['encoding'] - json.content content['content'] +if @result_object['contents'].is_a?(Array) + json.contents @result_object['contents'].each do |content| + json.name content['name'] + json.path content['path'] + json.sha content['sha'] + json.type content['type'] + json.size content['size'] + json.encoding content['encoding'] + json.content content['content'] + end +else + json.contents [] end \ No newline at end of file