From 245216964ba89e4974b5d924b5a8fab969e876a9 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 5 Jun 2020 11:34:28 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/repositories_helper.rb | 7 ++++++- app/views/repositories/_simple_entry.json.jbuilder | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index b0eea0e5..f27b359e 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -5,7 +5,12 @@ module RepositoriesHelper end def download_type(str) - default_type = %w(xlsx xls ppt pptx pdf zip 7z rar exe pdb obj idb png jpg gif tif psd svg) + default_type = %w(xlsx xls ppt pptx pdf zip 7z rar exe pdb obj idb) + default_type.include?(str&.downcase) + end + + def image_type?(str) + default_type = %w(png jpg gif tif psd svg) default_type.include?(str&.downcase) end diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index 0698769e..cdea42c8 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -1,6 +1,7 @@ file_name = entry['name'] file_type = file_name.to_s.split(".").last direct_download = download_type(file_type) +image_type = image_type?(file_type) json.name file_name json.sha entry['sha'] json.path entry['path'] @@ -10,6 +11,7 @@ json.content entry['content'].present? && !direct_download ? render_decode64_con json.target entry['target'] json.download_url entry['download_url'] json.direct_download direct_download +json.image_type image_type if entry['latest_commit'] json.partial! 'last_commit', entry: entry From 765946757782daaa676a3e3b4ab4967b45f0dd89 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 5 Jun 2020 11:36:30 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9image=5Ftype?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_simple_entry.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index cdea42c8..4e91aad3 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -7,7 +7,7 @@ json.sha entry['sha'] json.path entry['path'] json.type entry['type'] json.size entry['size'] -json.content entry['content'].present? && !direct_download ? render_decode64_content(entry['content']).force_encoding('UTF-8') : "" +json.content entry['content'].present? && ( !direct_download || !image_type ) ? render_decode64_content(entry['content']).force_encoding('UTF-8') : "" json.target entry['target'] json.download_url entry['download_url'] json.direct_download direct_download From b1cfc42217c4976b06fe6a4cfa63748bd0c40af2 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 5 Jun 2020 11:37:31 +0800 Subject: [PATCH 3/6] change image_type --- app/views/repositories/_simple_entry.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index 4e91aad3..450e1a49 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -7,7 +7,7 @@ json.sha entry['sha'] json.path entry['path'] json.type entry['type'] json.size entry['size'] -json.content entry['content'].present? && ( !direct_download || !image_type ) ? render_decode64_content(entry['content']).force_encoding('UTF-8') : "" +json.content entry['content'].present? && ( !direct_download && !image_type ) ? render_decode64_content(entry['content']).force_encoding('UTF-8') : "" json.target entry['target'] json.download_url entry['download_url'] json.direct_download direct_download From 4fe404708a496f06f3a557b40a88f5e191b45021 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 5 Jun 2020 11:39:18 +0800 Subject: [PATCH 4/6] change image_type --- app/helpers/repositories_helper.rb | 2 +- app/views/repositories/_simple_entry.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index f27b359e..bf2334dd 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -5,7 +5,7 @@ module RepositoriesHelper end def download_type(str) - default_type = %w(xlsx xls ppt pptx pdf zip 7z rar exe pdb obj idb) + default_type = %w(xlsx xls ppt pptx pdf zip 7z rar exe pdb obj idb png jpg gif tif psd svg) default_type.include?(str&.downcase) end diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index 450e1a49..cdea42c8 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -7,7 +7,7 @@ json.sha entry['sha'] json.path entry['path'] json.type entry['type'] json.size entry['size'] -json.content entry['content'].present? && ( !direct_download && !image_type ) ? render_decode64_content(entry['content']).force_encoding('UTF-8') : "" +json.content entry['content'].present? && !direct_download ? render_decode64_content(entry['content']).force_encoding('UTF-8') : "" json.target entry['target'] json.download_url entry['download_url'] json.direct_download direct_download From 3cd5c8480b180bf6c0198e66c212c97167496e93 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 5 Jun 2020 16:02:30 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=88=86=E6=94=AF=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/gitea/client_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/gitea/client_service.rb b/app/services/gitea/client_service.rb index 7fd990c6..58427637 100644 --- a/app/services/gitea/client_service.rb +++ b/app/services/gitea/client_service.rb @@ -21,6 +21,9 @@ class Gitea::ClientService < ApplicationService def post(url, params={}) puts "[gitea] request params: #{params}" request_url = [api_url, url].join('').freeze + Rails.logger.info("######_____api____request_url_______###############{request_url}") + Rails.logger.info("######_____api____request_params_______###############{params}") + auth_token = authen_params(params[:token]) response = conn(auth_token).post do |req| req.url "#{request_url}" From e38f00b330b7ae655432fde1a0139032c5cdde4e Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 5 Jun 2020 16:54:26 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9issue=E7=9A=84=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E5=92=8C=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index ae7e44a9..bad2ee69 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -336,8 +336,14 @@ class IssuesController < ApplicationController } ChangeTokenJob.perform_later(change_params) end + if @issue.issue_classify.to_s == "pull_request" + @issue&.pull_request&.update_attribute(:status, 2) + end else @issue&.project_trends&.update_all(action_type: "create") + if @issue.issue_classify.to_s == "pull_request" + @issue&.pull_request&.update_attribute(:status, 0) + end end if @issue.issue_classify == "issue" close_message = "close_issue"