From 5c26a6a877766db0ace166da833f0a088525bbc7 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 8 May 2023 16:33:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=96=87=E6=A1=88=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/projects/create_form.rb | 2 +- app/forms/projects/migrate_form.rb | 2 +- app/forms/projects/update_form.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/forms/projects/create_form.rb b/app/forms/projects/create_form.rb index 9c7424094..6b08d1f8f 100644 --- a/app/forms/projects/create_form.rb +++ b/app/forms/projects/create_form.rb @@ -4,7 +4,7 @@ class Projects::CreateForm < BaseForm :blockchain, :blockchain_token_all, :blockchain_init_token validates :user_id, :name, :repository_name, presence: true - validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "项目标识只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } + validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "项目标识长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } validates :name, length: { maximum: 50 } validates :repository_name, length: { maximum: 100 } diff --git a/app/forms/projects/migrate_form.rb b/app/forms/projects/migrate_form.rb index 1cb9b462e..4d81307ca 100644 --- a/app/forms/projects/migrate_form.rb +++ b/app/forms/projects/migrate_form.rb @@ -3,7 +3,7 @@ class Projects::MigrateForm < BaseForm :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner validates :user_id, :name, :repository_name, :clone_addr, presence: true - validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "项目标识只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } + validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "项目标识长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } validates :clone_addr, format: { with: CustomRegexp::URL_REGEX, multiline: true, message: "地址格式不正确" } validates :name, length: { maximum: 50 } validates :repository_name, length: { maximum: 100 } diff --git a/app/forms/projects/update_form.rb b/app/forms/projects/update_form.rb index 1a04b7fe4..1bd7ad68b 100644 --- a/app/forms/projects/update_form.rb +++ b/app/forms/projects/update_form.rb @@ -3,7 +3,7 @@ class Projects::UpdateForm < BaseForm validates :name, presence: true validates :name, length: { maximum: 50 } validates :description, length: { maximum: 200 } - validates :identifier, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: '项目标识只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾' } + validates :identifier, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: '项目标识长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾' } validate do check_project_category(project_category_id) From 5343fcf29ee4d4f89a486ba2299b53f5b15d62b1 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 8 May 2023 16:40:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=96=87=E6=A1=88=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/projects/create_form.rb | 2 +- app/forms/projects/migrate_form.rb | 2 +- app/forms/projects/update_form.rb | 2 +- config/locales/forms/projects_create_form.zh-CN.yml | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/forms/projects/create_form.rb b/app/forms/projects/create_form.rb index 6b08d1f8f..c133175c2 100644 --- a/app/forms/projects/create_form.rb +++ b/app/forms/projects/create_form.rb @@ -4,7 +4,7 @@ class Projects::CreateForm < BaseForm :blockchain, :blockchain_token_all, :blockchain_init_token validates :user_id, :name, :repository_name, presence: true - validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "项目标识长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } + validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } validates :name, length: { maximum: 50 } validates :repository_name, length: { maximum: 100 } diff --git a/app/forms/projects/migrate_form.rb b/app/forms/projects/migrate_form.rb index 4d81307ca..12a4ee617 100644 --- a/app/forms/projects/migrate_form.rb +++ b/app/forms/projects/migrate_form.rb @@ -3,7 +3,7 @@ class Projects::MigrateForm < BaseForm :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner validates :user_id, :name, :repository_name, :clone_addr, presence: true - validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "项目标识长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } + validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } validates :clone_addr, format: { with: CustomRegexp::URL_REGEX, multiline: true, message: "地址格式不正确" } validates :name, length: { maximum: 50 } validates :repository_name, length: { maximum: 100 } diff --git a/app/forms/projects/update_form.rb b/app/forms/projects/update_form.rb index 1bd7ad68b..226b2dc59 100644 --- a/app/forms/projects/update_form.rb +++ b/app/forms/projects/update_form.rb @@ -3,7 +3,7 @@ class Projects::UpdateForm < BaseForm validates :name, presence: true validates :name, length: { maximum: 50 } validates :description, length: { maximum: 200 } - validates :identifier, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: '项目标识长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾' } + validates :identifier, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: '长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾' } validate do check_project_category(project_category_id) diff --git a/config/locales/forms/projects_create_form.zh-CN.yml b/config/locales/forms/projects_create_form.zh-CN.yml index 54de8e71a..f319c3cd4 100644 --- a/config/locales/forms/projects_create_form.zh-CN.yml +++ b/config/locales/forms/projects_create_form.zh-CN.yml @@ -2,6 +2,10 @@ activemodel: attributes: projects/create_form: + name: 项目名称 + repository_name: 项目标识 + description: 项目简介 + projects/migrate_form: name: 项目名称 repository_name: 项目标识 description: 项目简介 \ No newline at end of file From 784553d894c50f39ee6a59b2e115f30f362167d6 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 8 May 2023 17:15:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fixed=20=E8=AF=AD=E8=A8=80=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/gitea/client_service.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/gitea/client_service.rb b/app/services/gitea/client_service.rb index fae4ae27e..b2b0aef11 100644 --- a/app/services/gitea/client_service.rb +++ b/app/services/gitea/client_service.rb @@ -221,6 +221,8 @@ class Gitea::ClientService < ApplicationService end [body, message] + rescue + return [{}, ""] end def json_parse!(body)