From 20cd41b5e917529d957edfefa1dab20ba4e75655 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 15 Jan 2026 15:01:51 +0800 Subject: [PATCH 01/31] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=96=B0=E5=BB=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/projects/tags_controller.rb | 15 +++++- .../api/v1/projects/tags/create_service.rb | 53 +++++++++++++++++++ .../tags/_simple_gitea_detail.json.jbuilder | 14 +++++ .../api/v1/projects/tags/create.json.jbuilder | 1 + .../api/v1/projects/tags/show.json.jbuilder | 2 +- config/routes/api.rb | 10 ++-- 6 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 app/services/api/v1/projects/tags/create_service.rb create mode 100644 app/views/api/v1/projects/tags/_simple_gitea_detail.json.jbuilder create mode 100644 app/views/api/v1/projects/tags/create.json.jbuilder diff --git a/app/controllers/api/v1/projects/tags_controller.rb b/app/controllers/api/v1/projects/tags_controller.rb index 44fdd9ba0..a9ff3f704 100644 --- a/app/controllers/api/v1/projects/tags_controller.rb +++ b/app/controllers/api/v1/projects/tags_controller.rb @@ -10,7 +10,13 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController @result_object = Api::V1::Projects::Tags::GetService.call(@project, params[:name], current_user&.gitea_token) end - before_action :require_operate_above, only: [:destroy] + before_action :require_operate_above, only: [:create, :destroy] + + def create + @result_object = Api::V1::Projects::Tags::CreateService.call(@project, tag_params, current_user&.gitea_token) + Rails.logger.info "create tag result: #{@result_object}" + @project.update_column(:updated_on, Time.now) + end def destroy @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, params[:name], current_user&.gitea_token) @@ -20,4 +26,11 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController return render_error('删除标签失败!') end end + + private + + def tag_params + params.require(:tag).permit(:tag_name, :target, :message) + end + end \ No newline at end of file diff --git a/app/services/api/v1/projects/tags/create_service.rb b/app/services/api/v1/projects/tags/create_service.rb new file mode 100644 index 000000000..e072d6912 --- /dev/null +++ b/app/services/api/v1/projects/tags/create_service.rb @@ -0,0 +1,53 @@ +class Api::V1::Projects::Tags::CreateService < ApplicationService + include ActiveModel::Model + + attr_accessor :project, :token, :owner, :repo, :tag_name, :target, :message + attr_accessor :gitea_data + + validates :tag_name, :target, :message, presence: true + + def initialize(project, params, token=nil) + @project = project + @owner = project&.owner.login + @repo = project&.identifier + @tag_name = params[:tag_name] + @target = params[:target] + @message = params[:message] + @token = token + end + + def call + raise Error, errors.full_messages.join(",") unless valid? + + check_tag_exist + excute_data_to_gitea + + gitea_data + end + + private + def request_params + { + access_token: token + } + end + + def request_body + { + tag_name: tag_name, + target: target, + message: message, + } + end + + def excute_data_to_gitea + @gitea_data = $gitea_client.post_repos_tags_by_owner_repo(owner, repo, {body: request_body.to_json, query: request_params}) rescue nil + raise Error, '创建标签失败!' unless @gitea_data.is_a?(Hash) + end + + def check_tag_exist + result = $gitea_hat_client.get_repos_tag_name_set_by_owner_repo(owner, repo, {query: request_params}) rescue nil + raise Error, '查询标签名称失败!' unless result.is_a?(Array) + raise Error, '新标签已存在!' if result.include?(@tag_name) + end +end \ No newline at end of file diff --git a/app/views/api/v1/projects/tags/_simple_gitea_detail.json.jbuilder b/app/views/api/v1/projects/tags/_simple_gitea_detail.json.jbuilder new file mode 100644 index 000000000..3c83482ba --- /dev/null +++ b/app/views/api/v1/projects/tags/_simple_gitea_detail.json.jbuilder @@ -0,0 +1,14 @@ +if tag.present? && tag.is_a?(Hash) + json.name tag["name"] + json.message tag["message"] + json.id tag["id"] + json.zipball_url render_zip_url(@owner, @repository, tag['name']) + json.tarball_url render_tar_url(@owner, @repository, tag['name']) + json.commit do + json.sha tag['commit']['sha'] + json.time_ago time_from_now(tag['commit']['created'].to_time) + json.created_at_unix tag['commit']['created'].to_time.to_i + end +else + json.name tag.name +end \ No newline at end of file diff --git a/app/views/api/v1/projects/tags/create.json.jbuilder b/app/views/api/v1/projects/tags/create.json.jbuilder new file mode 100644 index 000000000..a3be0a366 --- /dev/null +++ b/app/views/api/v1/projects/tags/create.json.jbuilder @@ -0,0 +1 @@ +json.partial! "api/v1/projects/tags/simple_gitea_detail", tag: @result_object \ No newline at end of file diff --git a/app/views/api/v1/projects/tags/show.json.jbuilder b/app/views/api/v1/projects/tags/show.json.jbuilder index a0e45fb7e..a3be0a366 100644 --- a/app/views/api/v1/projects/tags/show.json.jbuilder +++ b/app/views/api/v1/projects/tags/show.json.jbuilder @@ -1 +1 @@ -json.partial! "api/v1/projects/tags/simple_gitea_index_detail", tag: @result_object +json.partial! "api/v1/projects/tags/simple_gitea_detail", tag: @result_object \ No newline at end of file diff --git a/config/routes/api.rb b/config/routes/api.rb index 0380ca213..2b0d070cb 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -229,7 +229,7 @@ defaults format: :json do get :hooktasks end end - resources :branches, param: :name, only:[:index, :create, :destroy] do + resources :branches, param: :name, only:[:index, :create] do collection do get :gitee get :github @@ -238,11 +238,11 @@ defaults format: :json do patch :update_default_branch end end - match 'branches/*name', to: "branches#destroy", via: :all + match 'branches/*name', to: "branches#destroy", via: :all, constraints: { name: /[^\/]+/ } - resources :tags, param: :name, only: [:index, :show, :destroy] - delete 'tags/*name', to: "tags#destroy", via: :all - get 'tags/*name', to: "tags#show", via: :all + resources :tags, param: :name, only: [:index, :create] + delete 'tags/*name', to: "tags#destroy", via: :all, constraints: { name: /[^\/]+/ } + get 'tags/*name', to: "tags#show", via: :all, constraints: { name: /[^\/]+/ } get '/compare/:base...:head/files' => 'compare#files', :constraints => { base: /.+/, head: /.+/ } resources :commits, only: [:index] do From b96d32505c9ccbc6f844fb4a16a0148867ae46d4 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 15 Jan 2026 16:43:23 +0800 Subject: [PATCH 02/31] =?UTF-8?q?fix:=20release=5Fversion=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E9=95=BF=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20260115083448_change_column_to_version_releases.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/migrate/20260115083448_change_column_to_version_releases.rb diff --git a/db/migrate/20260115083448_change_column_to_version_releases.rb b/db/migrate/20260115083448_change_column_to_version_releases.rb new file mode 100644 index 000000000..f1af762e6 --- /dev/null +++ b/db/migrate/20260115083448_change_column_to_version_releases.rb @@ -0,0 +1,7 @@ +class ChangeColumnToVersionReleases < ActiveRecord::Migration[5.2] + def change + change_column :version_releases, :tarball_url, :text + change_column :version_releases, :zipball_url, :text + change_column :version_releases, :url, :text + end +end From 153afa0c77be46befe4eff650e2736701df1ad8d Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 16 Jan 2026 15:02:42 +0800 Subject: [PATCH 03/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9Apullrequest=20?= =?UTF-8?q?=E7=9A=84issue=E6=94=AF=E6=8C=81issue=5Ftag=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/issues/list_query_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/issues/list_query_service.rb b/app/services/issues/list_query_service.rb index f7c23ddfd..3a9bc8afc 100644 --- a/app/services/issues/list_query_service.rb +++ b/app/services/issues/list_query_service.rb @@ -48,7 +48,7 @@ class Issues::ListQueryService < ApplicationService issues = issues.where(fixed_version_id: params[:fixed_version_id]) if params[:fixed_version_id].present? && params[:fixed_version_id].to_s != "all" issues = issues.where(done_ratio: params[:done_ratio].to_i) if params[:done_ratio].present? && params[:done_ratio].to_s != "all" issues = issues.where(issue_type: params[:issue_type].to_s) if params[:issue_type].present? && params[:issue_type].to_s != "all" - issues = issues.joins(:issue_tags).where(issue_tags: {id: params[:issue_tag_id].to_i}) if params[:issue_tag_id].present? && params[:issue_tag_id].to_s != "all" + issues = issues.joins(:issue_tags).where(issue_tags: {id: params[:issue_tag_id].split(",")}) if params[:issue_tag_id].present? && params[:issue_tag_id].to_s != "all" issues.reorder("issues.#{order_name} #{order_type}") end From 74825b224e202866feab45c89739da9f7cd59684 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 20 Jan 2026 15:57:46 +0800 Subject: [PATCH 04/31] =?UTF-8?q?fixed=EF=BC=9A=E5=85=B3=E8=81=94issue?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=97=A0=E6=B3=95=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 03f739413..6355d0b43 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -165,17 +165,15 @@ class PullRequestsController < ApplicationController return normal_status(-1, "请输入正确的标记。") end end - if params[:attached_issue_ids].present? - if params[:attached_issue_ids].is_a?(Array) && params[:attached_issue_ids].size > 1 - return normal_status(-1, "最多只能关联一个疑修。") - elsif params[:attached_issue_ids].is_a?(Array) && params[:attached_issue_ids].size == 1 - @pull_request&.pull_attached_issues&.destroy_all - params[:attached_issue_ids].each do |issue| - PullAttachedIssue.create!(issue_id: issue, pull_request_id: @pull_request.id) - end - else - return normal_status(-1, "请输入正确的疑修。") + if params[:attached_issue_ids].is_a?(Array) && params[:attached_issue_ids].size > 1 + return normal_status(-1, "最多只能关联一个疑修。") + elsif params[:attached_issue_ids].is_a?(Array) #&& params[:attached_issue_ids].size == 1 + @pull_request&.pull_attached_issues&.destroy_all + params[:attached_issue_ids].each do |issue| + PullAttachedIssue.create!(issue_id: issue, pull_request_id: @pull_request.id) end + else + return normal_status(-1, "请输入正确的疑修。") end if params[:status_id].to_i == 5 @issue.issue_times.update_all(end_time: Time.now) From ea12dab204c685e0e2639068fd156ee773c39ad0 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 20 Jan 2026 16:15:38 +0800 Subject: [PATCH 05/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=88=A0=E9=99=A4=E5=8E=BB=E9=99=A4.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/tags_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/projects/tags_controller.rb b/app/controllers/api/v1/projects/tags_controller.rb index a9ff3f704..dd3e4f82d 100644 --- a/app/controllers/api/v1/projects/tags_controller.rb +++ b/app/controllers/api/v1/projects/tags_controller.rb @@ -7,7 +7,8 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController end def show - @result_object = Api::V1::Projects::Tags::GetService.call(@project, params[:name], current_user&.gitea_token) + @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] + @result_object = Api::V1::Projects::Tags::GetService.call(@project, @name, current_user&.gitea_token) end before_action :require_operate_above, only: [:create, :destroy] @@ -19,7 +20,8 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController end def destroy - @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, params[:name], current_user&.gitea_token) + @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] + @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, @name, current_user&.gitea_token) if @result_object return render_ok else From e6a4b09757846c3c3664160d07b65f81cc437d0c Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 09:13:39 +0800 Subject: [PATCH 06/31] =?UTF-8?q?fixed:=20=E5=88=9B=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=82=E6=95=B0=E7=BC=BA=E5=A4=B1=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/branches_controller.rb | 3 ++- app/views/repositories/create_file.json.jbuilder | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/projects/branches_controller.rb b/app/controllers/api/v1/projects/branches_controller.rb index e2d04eeb6..8837bcf0e 100644 --- a/app/controllers/api/v1/projects/branches_controller.rb +++ b/app/controllers/api/v1/projects/branches_controller.rb @@ -40,7 +40,8 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController end def destroy - @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, params[:name], current_user&.gitea_token) + @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] + @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, @name, current_user&.gitea_token) if @result_object @project.update_column(:updated_on, Time.now) # 有开启的pr需要一同关闭 diff --git a/app/views/repositories/create_file.json.jbuilder b/app/views/repositories/create_file.json.jbuilder index 5687ee731..81133218a 100644 --- a/app/views/repositories/create_file.json.jbuilder +++ b/app/views/repositories/create_file.json.jbuilder @@ -1,8 +1,8 @@ -json.name @file['content']['name'] -json.sha @file['content']['sha'] -json.size @file['content']['size'] -json.content @file['content']['content'] -json.encoding @file['content']['encoding'] +json.name @file['content'].present? ? @file['content']['name'] : "" +json.sha @file['content'].present? ? @file['content']['sha'] : "" +json.size @file['content'].present? ? @file['content']['size'] : "" +json.content @file['content'].present? ? @file['content']['content'] : "" +json.encoding @file['content'].present? ? @file['content']['encoding'] : "" json.pr_id @pull_issue.try(:id) json.commit do json.message @file['commit']['message'] From 4a4fe2f223da64a72798097058ed3d615227428f Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 09:21:13 +0800 Subject: [PATCH 07/31] =?UTF-8?q?fixed:=20=E5=88=9B=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=82=E6=95=B0=E7=BC=BA=E5=A4=B1=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/create_file.json.jbuilder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/repositories/create_file.json.jbuilder b/app/views/repositories/create_file.json.jbuilder index 81133218a..165fa2445 100644 --- a/app/views/repositories/create_file.json.jbuilder +++ b/app/views/repositories/create_file.json.jbuilder @@ -1,8 +1,8 @@ -json.name @file['content'].present? ? @file['content']['name'] : "" +json.name @file['content'].present? ? @file['content']['name'] : 怕rams[:filepath] json.sha @file['content'].present? ? @file['content']['sha'] : "" json.size @file['content'].present? ? @file['content']['size'] : "" -json.content @file['content'].present? ? @file['content']['content'] : "" -json.encoding @file['content'].present? ? @file['content']['encoding'] : "" +json.content @file['content'].present? ? @file['content']['content'] : params[:content] +json.encoding @file['content'].present? ? @file['content']['encoding'] : "base64" json.pr_id @pull_issue.try(:id) json.commit do json.message @file['commit']['message'] From 4248c430238c19aae6bdc1789c9e5ee79d1efc96 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 09:22:13 +0800 Subject: [PATCH 08/31] =?UTF-8?q?fixed:=20=E5=88=9B=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=82=E6=95=B0=E7=BC=BA=E5=A4=B1=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/create_file.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/create_file.json.jbuilder b/app/views/repositories/create_file.json.jbuilder index 165fa2445..bf85ba921 100644 --- a/app/views/repositories/create_file.json.jbuilder +++ b/app/views/repositories/create_file.json.jbuilder @@ -1,4 +1,4 @@ -json.name @file['content'].present? ? @file['content']['name'] : 怕rams[:filepath] +json.name @file['content'].present? ? @file['content']['name'] : params[:filepath] json.sha @file['content'].present? ? @file['content']['sha'] : "" json.size @file['content'].present? ? @file['content']['size'] : "" json.content @file['content'].present? ? @file['content']['content'] : params[:content] From 006054f424715cc2822d5ff0d566a6eaca10c4b1 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 09:45:59 +0800 Subject: [PATCH 09/31] =?UTF-8?q?fixed:=20=E5=90=88=E5=B9=B6=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9Estatus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 1 + app/views/pull_requests/edit.json.jbuilder | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 6355d0b43..7aa1fa4e8 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -94,6 +94,7 @@ class PullRequestsController < ApplicationController @fork_project_user_name = @pull_request&.fork_project&.owner.try(:show_real_name) @fork_project_user = @pull_request&.fork_project&.owner.try(:login) @fork_project_identifier = @pull_request&.fork_project&.repository.try(:identifier) + @gitea_pull = Gitea::PullRequest::GetService.call(@owner.login, @repository.identifier, @pull_request.gitea_number, @owner&.gitea_token) end def update diff --git a/app/views/pull_requests/edit.json.jbuilder b/app/views/pull_requests/edit.json.jbuilder index 08cefcb91..3ffa2d827 100644 --- a/app/views/pull_requests/edit.json.jbuilder +++ b/app/views/pull_requests/edit.json.jbuilder @@ -13,6 +13,8 @@ json.commits_count @pull_request.commits_count json.files_count @pull_request.files_count json.comments_count @pull_request.comments_count json.reviewers @pull_request.reviewers.pluck(:login) +json.mergeable @gitea_pull["mergeable"] +json.state @gitea_pull["state"] json.attached_issues @pull_request.attached_issues.each do |issue| json.(issue, :id, :subject, :project_issues_index) end From a8140cf0a6c238f21c0c5b7fa83fd97623a2ea98 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 09:52:58 +0800 Subject: [PATCH 10/31] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Apullrequest?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=8E=A5=E5=8F=A3status=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pull_requests/edit.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/pull_requests/edit.json.jbuilder b/app/views/pull_requests/edit.json.jbuilder index 3ffa2d827..dc01f99ef 100644 --- a/app/views/pull_requests/edit.json.jbuilder +++ b/app/views/pull_requests/edit.json.jbuilder @@ -15,6 +15,7 @@ json.comments_count @pull_request.comments_count json.reviewers @pull_request.reviewers.pluck(:login) json.mergeable @gitea_pull["mergeable"] json.state @gitea_pull["state"] +json.pull_request_staus @pull_request.status == 1 ? "merged" : (@pull_request.status == 2 ? "closed" : "open") json.attached_issues @pull_request.attached_issues.each do |issue| json.(issue, :id, :subject, :project_issues_index) end From 09add4f0806f75b4a6bf25307ae6d9ed03d801c8 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 22 Jan 2026 11:01:43 +0800 Subject: [PATCH 11/31] =?UTF-8?q?=E7=89=B9=E6=AE=8Aurl=E8=BD=ACyi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index a5a740de7..8ffede5cc 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -294,7 +294,7 @@ class RepositoriesController < ApplicationController def archive domain = GiteaService.gitea_config[:domain] api_url = GiteaService.gitea_config[:base_url] - archive_url = "/repos/#{@owner.login}/#{@repository.identifier}/archive/#{Addressable::URI.escape(params[:archive])}" + archive_url = "/repos/#{@owner.login}/#{@repository.identifier}/archive/#{URI.encode(params[:archive])}" file_path = [domain, api_url, archive_url].join file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("?") From 26fb01cfd8c5003fd498fc2a51b6d6496ad7bbc4 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 11:37:41 +0800 Subject: [PATCH 12/31] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=85=B3?= =?UTF-8?q?=E8=81=94=E7=96=91=E4=BF=AE=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 8 +++++++- app/models/journal.rb | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 7aa1fa4e8..fc5d06295 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -151,7 +151,7 @@ class PullRequestsController < ApplicationController #if params[:issue_tag_ids].is_a?(Array) && params[:issue_tag_ids].size > 1 # return normal_status(-1, "最多只能创建一个标记。") #elsif params[:issue_tag_ids].is_a?(Array) && params[:issue_tag_ids].size == 1 - if params[:issue_tag_ids].is_a?(Array) && params[:issue_tag_ids].present? + if params[:issue_tag_ids].is_a?(Array) #&& params[:issue_tag_ids].present? new_issue_tag_ids = params[:issue_tag_ids] now_issue_tag_ids = @issue.issue_tags.pluck(:id) if !(now_issue_tag_ids & new_issue_tag_ids).empty? || !(now_issue_tag_ids.empty? && new_issue_tag_ids.empty?) @@ -169,6 +169,12 @@ class PullRequestsController < ApplicationController if params[:attached_issue_ids].is_a?(Array) && params[:attached_issue_ids].size > 1 return normal_status(-1, "最多只能关联一个疑修。") elsif params[:attached_issue_ids].is_a?(Array) #&& params[:attached_issue_ids].size == 1 + new_attached_issue_ids = params[:attached_issue_ids] + now_attached_issue_ids = @issue.attached_issues.pluck(:id) + if !(now_attached_issue_ids & new_attached_issue_ids).empty? || !(now_attached_issue_ids.empty? && new_attached_issue_ids.empty?) + journal = @issue.journals.create!({user_id: current_user.id, operate_by: 'Issue'}) + journal.journal_details.create!({property: "attached_issue", prop_key: "#{new_issue_tag_ids.size}", old_value: now_attached_issue_ids.join(","), value: new_attached_issue_ids.join(",")}) + end @pull_request&.pull_attached_issues&.destroy_all params[:attached_issue_ids].each do |issue| PullAttachedIssue.create!(issue_id: issue, pull_request_id: @pull_request.id) diff --git a/app/models/journal.rb b/app/models/journal.rb index bf7db2d2a..da930ccbb 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -553,6 +553,16 @@ class Journal < ApplicationRecord content += "将标记由#{old_value}更改为#{new_value}" end return content + when 'attached_issue' + old_value = Issue.where(id: detail.old_value.split(",")).pluck(:subject).join("、") + new_value = Issue.where(id: detail.value.split(",")).pluck(:subject).join("、") + if old_value.nil? || old_value.blank? + content += "添加了#{new_value}关联疑修" + else + new_value = "无" if new_value.blank? + content += "将关联疑修由#{old_value}更改为#{new_value}" + end + return content when 'assigner' old_value = User.where(id: detail.old_value.split(",")).map{|u| u.real_name}.join("、") new_value = User.where(id: detail.value.split(",")).map{|u| u.real_name}.join("、") From 2e496a17c084b6004ea1f3b9d8db72296240f7e0 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 11:40:40 +0800 Subject: [PATCH 13/31] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=85=B3?= =?UTF-8?q?=E8=81=94=E7=96=91=E4=BF=AE=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index fc5d06295..1b10b136b 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -170,7 +170,7 @@ class PullRequestsController < ApplicationController return normal_status(-1, "最多只能关联一个疑修。") elsif params[:attached_issue_ids].is_a?(Array) #&& params[:attached_issue_ids].size == 1 new_attached_issue_ids = params[:attached_issue_ids] - now_attached_issue_ids = @issue.attached_issues.pluck(:id) + now_attached_issue_ids = @pull_request.attached_issues.pluck(:id) if !(now_attached_issue_ids & new_attached_issue_ids).empty? || !(now_attached_issue_ids.empty? && new_attached_issue_ids.empty?) journal = @issue.journals.create!({user_id: current_user.id, operate_by: 'Issue'}) journal.journal_details.create!({property: "attached_issue", prop_key: "#{new_issue_tag_ids.size}", old_value: now_attached_issue_ids.join(","), value: new_attached_issue_ids.join(",")}) From b1e59da99c3b754a623fb4020913b294ccbd424d Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 11:49:25 +0800 Subject: [PATCH 14/31] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=85=B3?= =?UTF-8?q?=E8=81=94=E7=96=91=E4=BF=AE=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 1b10b136b..4c14f6ff8 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -173,7 +173,7 @@ class PullRequestsController < ApplicationController now_attached_issue_ids = @pull_request.attached_issues.pluck(:id) if !(now_attached_issue_ids & new_attached_issue_ids).empty? || !(now_attached_issue_ids.empty? && new_attached_issue_ids.empty?) journal = @issue.journals.create!({user_id: current_user.id, operate_by: 'Issue'}) - journal.journal_details.create!({property: "attached_issue", prop_key: "#{new_issue_tag_ids.size}", old_value: now_attached_issue_ids.join(","), value: new_attached_issue_ids.join(",")}) + journal.journal_details.create!({property: "attached_issue", prop_key: "#{new_attached_issue_ids.size}", old_value: now_attached_issue_ids.join(","), value: new_attached_issue_ids.join(",")}) end @pull_request&.pull_attached_issues&.destroy_all params[:attached_issue_ids].each do |issue| From 21a9162dbafe113a7f9ded733d5722934ac1e41b Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 14:06:19 +0800 Subject: [PATCH 15/31] =?UTF-8?q?fixed:=E6=97=A0=E6=B3=95=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=A0=87=E8=AE=B0=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 4c14f6ff8..a05ad9077 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -147,7 +147,7 @@ class PullRequestsController < ApplicationController @pull_request.gitea_number, @requests_params, current_user.gitea_token) if gitea_pull[:status] === :success - if params[:issue_tag_ids].present? + #if params[:issue_tag_ids].present? #if params[:issue_tag_ids].is_a?(Array) && params[:issue_tag_ids].size > 1 # return normal_status(-1, "最多只能创建一个标记。") #elsif params[:issue_tag_ids].is_a?(Array) && params[:issue_tag_ids].size == 1 @@ -165,7 +165,7 @@ class PullRequestsController < ApplicationController else return normal_status(-1, "请输入正确的标记。") end - end + #end if params[:attached_issue_ids].is_a?(Array) && params[:attached_issue_ids].size > 1 return normal_status(-1, "最多只能关联一个疑修。") elsif params[:attached_issue_ids].is_a?(Array) #&& params[:attached_issue_ids].size == 1 From 81b34f941de2cd7bb7b58e589ef15ba8cf2a5ab2 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 14:24:16 +0800 Subject: [PATCH 16/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E6=95=B0=E8=BF=94=E5=9B=9E=E6=96=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pull_requests/show.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/pull_requests/show.json.jbuilder b/app/views/pull_requests/show.json.jbuilder index d2c928b75..8500bf6bb 100644 --- a/app/views/pull_requests/show.json.jbuilder +++ b/app/views/pull_requests/show.json.jbuilder @@ -5,8 +5,8 @@ json.project_identifier @project.identifier json.pr_time time_from_now(@pull_request.updated_at) json.commits_count @gitea_pull["commit_num"] json.files_count @gitea_pull["changed_files"] -json.comments_count @issue.journals.parent_journals.size -json.comments_total_count @issue.get_journals_size +json.comments_count @issue.jounrals.where.not(notes: nil).size +json.comments_total_count @issue.jounrals.where.not(notes: nil).size json.can_reopen @pull_request.closed? json.assign_user do json.partial! 'users/user_simple', user: @issue_assign_to From dfd7e40b6ab232685ed2cfc1ecb6c254971e455d Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 14:25:18 +0800 Subject: [PATCH 17/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E6=95=B0=E8=BF=94=E5=9B=9E=E6=96=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pull_requests/show.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/pull_requests/show.json.jbuilder b/app/views/pull_requests/show.json.jbuilder index 8500bf6bb..02ac4c47c 100644 --- a/app/views/pull_requests/show.json.jbuilder +++ b/app/views/pull_requests/show.json.jbuilder @@ -5,8 +5,8 @@ json.project_identifier @project.identifier json.pr_time time_from_now(@pull_request.updated_at) json.commits_count @gitea_pull["commit_num"] json.files_count @gitea_pull["changed_files"] -json.comments_count @issue.jounrals.where.not(notes: nil).size -json.comments_total_count @issue.jounrals.where.not(notes: nil).size +json.comments_count @issue.journals.where.not(notes: nil).size +json.comments_total_count @issue.journals.where.not(notes: nil).size json.can_reopen @pull_request.closed? json.assign_user do json.partial! 'users/user_simple', user: @issue_assign_to From 8dd213d40832cc180120047df469225563edd0b1 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 14:33:18 +0800 Subject: [PATCH 18/31] =?UTF-8?q?fixed:=E6=9C=AA=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E4=B8=8D=E4=BA=A7=E7=94=9F=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index a05ad9077..5bc81c659 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -152,9 +152,9 @@ class PullRequestsController < ApplicationController # return normal_status(-1, "最多只能创建一个标记。") #elsif params[:issue_tag_ids].is_a?(Array) && params[:issue_tag_ids].size == 1 if params[:issue_tag_ids].is_a?(Array) #&& params[:issue_tag_ids].present? - new_issue_tag_ids = params[:issue_tag_ids] - now_issue_tag_ids = @issue.issue_tags.pluck(:id) - if !(now_issue_tag_ids & new_issue_tag_ids).empty? || !(now_issue_tag_ids.empty? && new_issue_tag_ids.empty?) + new_issue_tag_ids = params[:issue_tag_ids].sort! + now_issue_tag_ids = @issue.issue_tags.pluck(:id).sort! + if (!(now_issue_tag_ids & new_issue_tag_ids).empty? || !(now_issue_tag_ids.empty? && new_issue_tag_ids.empty?)) && new_issue_tag_ids != now_issue_tag_ids journal = @issue.journals.create!({user_id: current_user.id, operate_by: 'Issue'}) journal.journal_details.create!({property: "issue_tag", prop_key: "#{new_issue_tag_ids.size}", old_value: now_issue_tag_ids.join(","), value: new_issue_tag_ids.join(",")}) end From 3be440866128aa83263d02cc67b7ec7cbf246ff4 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 14:35:46 +0800 Subject: [PATCH 19/31] =?UTF-8?q?fixed:=E6=9C=AA=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=85=B3=E8=81=94=E7=96=91=E4=BF=AE=E4=B8=8D=E4=BA=A7=E7=94=9F?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 5bc81c659..01d3908df 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -169,9 +169,9 @@ class PullRequestsController < ApplicationController if params[:attached_issue_ids].is_a?(Array) && params[:attached_issue_ids].size > 1 return normal_status(-1, "最多只能关联一个疑修。") elsif params[:attached_issue_ids].is_a?(Array) #&& params[:attached_issue_ids].size == 1 - new_attached_issue_ids = params[:attached_issue_ids] - now_attached_issue_ids = @pull_request.attached_issues.pluck(:id) - if !(now_attached_issue_ids & new_attached_issue_ids).empty? || !(now_attached_issue_ids.empty? && new_attached_issue_ids.empty?) + new_attached_issue_ids = params[:attached_issue_ids].sort! + now_attached_issue_ids = @pull_request.attached_issues.pluck(:id).sort! + if (!(now_attached_issue_ids & new_attached_issue_ids).empty? || !(now_attached_issue_ids.empty? && new_attached_issue_ids.empty?)) && new_attached_issue_ids != now_attached_issue_ids journal = @issue.journals.create!({user_id: current_user.id, operate_by: 'Issue'}) journal.journal_details.create!({property: "attached_issue", prop_key: "#{new_attached_issue_ids.size}", old_value: now_attached_issue_ids.join(","), value: new_attached_issue_ids.join(",")}) end From 6f90c5ff88dce1cc6e274f062ed552c5d0136ab1 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 14:48:19 +0800 Subject: [PATCH 20/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E5=88=86?= =?UTF-8?q?=E6=94=AF=E6=A0=87=E7=AD=BE=E5=88=A0=E9=99=A4=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E4=BC=A0=E8=BE=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/branches_controller.rb | 2 +- app/controllers/api/v1/projects/tags_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/projects/branches_controller.rb b/app/controllers/api/v1/projects/branches_controller.rb index 8837bcf0e..00ff504d8 100644 --- a/app/controllers/api/v1/projects/branches_controller.rb +++ b/app/controllers/api/v1/projects/branches_controller.rb @@ -41,7 +41,7 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController def destroy @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] - @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, @name, current_user&.gitea_token) + @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, Base64.decode64(@name), current_user&.gitea_token) if @result_object @project.update_column(:updated_on, Time.now) # 有开启的pr需要一同关闭 diff --git a/app/controllers/api/v1/projects/tags_controller.rb b/app/controllers/api/v1/projects/tags_controller.rb index dd3e4f82d..32116aef2 100644 --- a/app/controllers/api/v1/projects/tags_controller.rb +++ b/app/controllers/api/v1/projects/tags_controller.rb @@ -8,7 +8,7 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController def show @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] - @result_object = Api::V1::Projects::Tags::GetService.call(@project, @name, current_user&.gitea_token) + @result_object = Api::V1::Projects::Tags::GetService.call(@project, Base64.decode64(@name), current_user&.gitea_token) end before_action :require_operate_above, only: [:create, :destroy] @@ -21,7 +21,7 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController def destroy @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] - @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, @name, current_user&.gitea_token) + @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, Base64.decode64(@name), current_user&.gitea_token) if @result_object return render_ok else From d5ef64c31db86bf6d9d6951d3859b447483a9a32 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 15:17:04 +0800 Subject: [PATCH 21/31] =?UTF-8?q?fixed=EF=BC=9A=E4=BC=A0=E9=80=92=E8=87=B3?= =?UTF-8?q?gitea=E9=9C=80=E8=A6=81=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/branches_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/branches_controller.rb b/app/controllers/api/v1/projects/branches_controller.rb index 00ff504d8..d6ce5d2cf 100644 --- a/app/controllers/api/v1/projects/branches_controller.rb +++ b/app/controllers/api/v1/projects/branches_controller.rb @@ -41,7 +41,7 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController def destroy @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] - @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, Base64.decode64(@name), current_user&.gitea_token) + @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, URI.escape(Base64.decode64(@name)), current_user&.gitea_token) if @result_object @project.update_column(:updated_on, Time.now) # 有开启的pr需要一同关闭 From 4341f19c2167bef3cab48b576a2870c2f69f9324 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 16:19:16 +0800 Subject: [PATCH 22/31] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Adelete?= =?UTF-8?q?=E5=88=86=E6=94=AF=E5=92=8C=E6=A0=87=E7=AD=BE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/projects/branches_controller.rb | 23 +++++++++++++++++-- .../api/v1/projects/tags_controller.rb | 11 ++++++++- .../v1/projects/branches/delete_service.rb | 2 +- .../api/v1/projects/tags/delete_service.rb | 2 +- config/routes/api.rb | 7 +++++- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/projects/branches_controller.rb b/app/controllers/api/v1/projects/branches_controller.rb index d6ce5d2cf..6003c3005 100644 --- a/app/controllers/api/v1/projects/branches_controller.rb +++ b/app/controllers/api/v1/projects/branches_controller.rb @@ -32,16 +32,35 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController @result_object = Api::V1::Projects::Branches::AllListService.call(@project, current_user&.gitea_token) end - before_action :require_operate_above, only: [:create, :destroy, :restore] + before_action :require_operate_above, only: [:create, :delete, :destroy, :restore] def create @result_object = Api::V1::Projects::Branches::CreateService.call(@project, branch_params, current_user&.gitea_token) @project.update_column(:updated_on, Time.now) end + def delete + @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, params[:branch_name], current_user&.gitea_token) + if @result_object + @project.update_column(:updated_on, Time.now) + # 有开启的pr需要一同关闭 + # 1、删除本仓库中存在未关闭的pr,即本仓库分支1->分支2 + # 2、如果是fork仓库,考虑删除主仓库中存在未关闭的pr,即本仓库:分支1->主:分支2,同时分两种删除:1删除本仓库分支1,2删除主仓库分支2 + close_pull_requests_by(@project, params[:branch_name]) + if @project.forked_from_project_id.present? + # fork项目中删除分支 + close_pull_requests_by(@project.fork_project, params[:branch_name]) + end + + return render_ok + else + return render_error('删除分支失败!') + end + end + def destroy @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] - @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, URI.escape(Base64.decode64(@name)), current_user&.gitea_token) + @result_object = Api::V1::Projects::Branches::DeleteService.call(@project, Base64.decode64(@name), current_user&.gitea_token) if @result_object @project.update_column(:updated_on, Time.now) # 有开启的pr需要一同关闭 diff --git a/app/controllers/api/v1/projects/tags_controller.rb b/app/controllers/api/v1/projects/tags_controller.rb index 32116aef2..88de00d61 100644 --- a/app/controllers/api/v1/projects/tags_controller.rb +++ b/app/controllers/api/v1/projects/tags_controller.rb @@ -11,7 +11,7 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController @result_object = Api::V1::Projects::Tags::GetService.call(@project, Base64.decode64(@name), current_user&.gitea_token) end - before_action :require_operate_above, only: [:create, :destroy] + before_action :require_operate_above, only: [:create, :delete, :destroy] def create @result_object = Api::V1::Projects::Tags::CreateService.call(@project, tag_params, current_user&.gitea_token) @@ -19,6 +19,15 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController @project.update_column(:updated_on, Time.now) end + def delete + @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, params[:branch_name], current_user&.gitea_token) + if @result_object + return render_ok + else + return render_error('删除标签失败!') + end + end + def destroy @name = params[:name].include?('.json') ? params[:name][0..-6] : params[:name] @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, Base64.decode64(@name), current_user&.gitea_token) diff --git a/app/services/api/v1/projects/branches/delete_service.rb b/app/services/api/v1/projects/branches/delete_service.rb index 341079273..47520d3be 100644 --- a/app/services/api/v1/projects/branches/delete_service.rb +++ b/app/services/api/v1/projects/branches/delete_service.rb @@ -32,7 +32,7 @@ class Api::V1::Projects::Branches::DeleteService < ApplicationService def excute_data_to_gitea begin - @gitea_data = $gitea_client.delete_repos_branches_by_owner_repo_branch(owner, repo, CGI.escape(branch_name), {query: request_params}) + @gitea_data = $gitea_client.delete_repos_branches_by_owner_repo_branch(owner, repo, URI.encode(branch_name), {query: request_params}) rescue => e raise Error, '保护分支无法删除!' if e.to_s.include?("branch protected") raise Error, '删除分支失败!' diff --git a/app/services/api/v1/projects/tags/delete_service.rb b/app/services/api/v1/projects/tags/delete_service.rb index 8f898bf1a..c5f3c375d 100644 --- a/app/services/api/v1/projects/tags/delete_service.rb +++ b/app/services/api/v1/projects/tags/delete_service.rb @@ -32,7 +32,7 @@ class Api::V1::Projects::Tags::DeleteService < ApplicationService def excute_data_to_gitea begin - @gitea_data = $gitea_client.delete_repos_tags_by_owner_repo_tag(owner, repo, CGI.escape(tag_name), {query: request_params}) + @gitea_data = $gitea_client.delete_repos_tags_by_owner_repo_tag(owner, repo, URI.encode(tag_name), {query: request_params}) rescue => e raise Error, '请先删除发行版!' if e.to_s.include?("409") raise Error, '删除标签失败!' diff --git a/config/routes/api.rb b/config/routes/api.rb index 2b0d070cb..b33d68af0 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -235,12 +235,17 @@ defaults format: :json do get :github get :all post :restore + post :delete patch :update_default_branch end end match 'branches/*name', to: "branches#destroy", via: :all, constraints: { name: /[^\/]+/ } - resources :tags, param: :name, only: [:index, :create] + resources :tags, param: :name, only: [:index, :create] do + collection do + post :delete + end + end delete 'tags/*name', to: "tags#destroy", via: :all, constraints: { name: /[^\/]+/ } get 'tags/*name', to: "tags#show", via: :all, constraints: { name: /[^\/]+/ } get '/compare/:base...:head/files' => 'compare#files', :constraints => { base: /.+/, head: /.+/ } From 0ea1a843da787f98612bb1a41de115fd2ca0e8b5 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 22 Jan 2026 16:25:28 +0800 Subject: [PATCH 23/31] fixed: branch_name to tag_name --- app/controllers/api/v1/projects/tags_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/tags_controller.rb b/app/controllers/api/v1/projects/tags_controller.rb index 88de00d61..0fb860715 100644 --- a/app/controllers/api/v1/projects/tags_controller.rb +++ b/app/controllers/api/v1/projects/tags_controller.rb @@ -20,7 +20,7 @@ class Api::V1::Projects::TagsController < Api::V1::BaseController end def delete - @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, params[:branch_name], current_user&.gitea_token) + @result_object = Api::V1::Projects::Tags::DeleteService.call(@project, params[:tag_name], current_user&.gitea_token) if @result_object return render_ok else From a8ec291050efc6e5ae1c3516d6e3487255ba5168 Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 23 Jan 2026 08:50:19 +0800 Subject: [PATCH 24/31] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=88=86?= =?UTF-8?q?=E6=94=AF=E5=90=8D=E4=B8=8E=E6=A0=87=E7=AD=BE=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E7=9B=B8=E5=90=8C=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/projects/branches/create_service.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/services/api/v1/projects/branches/create_service.rb b/app/services/api/v1/projects/branches/create_service.rb index 39964e402..165bafe8e 100644 --- a/app/services/api/v1/projects/branches/create_service.rb +++ b/app/services/api/v1/projects/branches/create_service.rb @@ -39,8 +39,15 @@ class Api::V1::Projects::Branches::CreateService < ApplicationService end def excute_data_to_gitea - @gitea_data = $gitea_client.post_repos_branches_by_owner_repo(owner, repo, {body: request_body.to_json, query: request_params}) rescue nil - raise Error, '创建分支失败!' unless @gitea_data.is_a?(Hash) + begin + @gitea_data = $gitea_client.post_repos_branches_by_owner_repo(owner, repo, {body: request_body.to_json, query: request_params}) + rescue Gitea::Api::ServerError => e + if e.http_code == 409 && e.to_s.include?("The branch with the same tag already exists") + raise Error, '创建分支失败,分支名称与标签名称不能相同!' + else + raise Error, '创建分支失败!' + end + end end def check_branch_exist From 47832df856da812c7b0f842515295f9f37a4a850 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 15:09:10 +0800 Subject: [PATCH 25/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E5=AD=97=E7=AC=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index a5a740de7..cca6d0536 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -83,7 +83,7 @@ class RepositoriesController < ApplicationController end def sub_entries - file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip)) + file_path_uri = URI.parse(URI.encode(params[:filepath].to_s)).gsub!("&", "%26") tip_exception('不可访问') if params[:filepath].to_s.include?("chinese_dictionary.txt") if @project.educoder? if params[:type] === 'file' From 7759ea558c3d82e40f912f07ea389511d9422dc2 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 15:26:36 +0800 Subject: [PATCH 26/31] =?UTF-8?q?fixed=EF=BC=9A=E4=BB=A3=E7=A0=81=E5=9B=9E?= =?UTF-8?q?=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ea473d14f..fa45a1dea 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -83,7 +83,7 @@ class RepositoriesController < ApplicationController end def sub_entries - file_path_uri = URI.parse(URI.encode(params[:filepath].to_s)).gsub!("&", "%26") + file_path_uri = URI.parse(URI.encode(params[:filepath].to_s)) tip_exception('不可访问') if params[:filepath].to_s.include?("chinese_dictionary.txt") if @project.educoder? if params[:type] === 'file' From aab613ebcef65cdbdd42e17d74da69a971ed73d6 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 15:42:07 +0800 Subject: [PATCH 27/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=8E=BB=E9=99=A4=E7=A9=BA=E6=A0=BC=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index fa45a1dea..ad7acc986 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -337,7 +337,7 @@ class RepositoriesController < ApplicationController # TODO 获取最新commit信息 def project_commits if params[:filepath].present? - file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip)) + file_path_uri = URI.parse(URI.encode(params[:filepath].to_s)) Gitea::Repository::Commits::FileListService.new(@project.owner.login, @project.identifier, file_path_uri, sha: get_ref, page: 1, limit: 1, token: @project&.owner&.gitea_token).call else From 6c56712573a7330c77158a4e7a5f9ec26a728b7f Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 15:51:29 +0800 Subject: [PATCH 28/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E5=AD=97=E7=AC=A6=E5=87=BD=E6=95=B0=E4=BD=BF=E7=94=A8?= =?UTF-8?q?uri.escape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/commits_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/commits_controller.rb b/app/controllers/api/v1/projects/commits_controller.rb index b80d09750..141bbf789 100644 --- a/app/controllers/api/v1/projects/commits_controller.rb +++ b/app/controllers/api/v1/projects/commits_controller.rb @@ -12,7 +12,7 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController def files if params[:filepath].present? - @result_object = $gitea_hat_client.get_repos_commits_files_by_owner_repo_sha_filepath(@project&.owner.login, @project&.identifier, params[:sha], CGI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}}) + @result_object = $gitea_hat_client.get_repos_commits_files_by_owner_repo_sha_filepath(@project&.owner.login, @project&.identifier, params[:sha], URI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}}) else @result_object = $gitea_hat_client.get_repos_commits_files_by_owner_repo_sha(@project&.owner.login, @project&.identifier, params[:sha], {query: {token: current_user&.gitea_token, page: page, limit: limit}}) end From c8b80c04d6a7ac6cfe2722541b73dfe00b290594 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 15:53:58 +0800 Subject: [PATCH 29/31] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E5=AD=97=E7=AC=A6=E5=87=BD=E6=95=B0=E4=BD=BF=E7=94=A8?= =?UTF-8?q?uri.escape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/runs_controller.rb | 2 +- app/controllers/api/v1/projects/pulls/pulls_controller.rb | 2 +- app/controllers/repositories_controller.rb | 2 +- app/helpers/projects_helper.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/projects/actions/runs_controller.rb b/app/controllers/api/v1/projects/actions/runs_controller.rb index 474ab8d91..9119b73e4 100644 --- a/app/controllers/api/v1/projects/actions/runs_controller.rb +++ b/app/controllers/api/v1/projects/actions/runs_controller.rb @@ -51,7 +51,7 @@ class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::B domain = GiteaService.gitea_config[:domain] api_url = GiteaService.gitea_config[:hat_base_url] - url = "/repos/#{@owner.login}/#{@repository.identifier}/actions/runs/#{CGI.escape(params[:run_id])}/jobs/#{CGI.escape(params[:job])}/logs" + url = "/repos/#{@owner.login}/#{@repository.identifier}/actions/runs/#{URI.escape(params[:run_id])}/jobs/#{URI.escape(params[:job])}/logs" file_path = [domain, api_url, url].join file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("?") diff --git a/app/controllers/api/v1/projects/pulls/pulls_controller.rb b/app/controllers/api/v1/projects/pulls/pulls_controller.rb index af6a36c2b..9f8db2f42 100644 --- a/app/controllers/api/v1/projects/pulls/pulls_controller.rb +++ b/app/controllers/api/v1/projects/pulls/pulls_controller.rb @@ -37,7 +37,7 @@ class Api::V1::Projects::Pulls::PullsController < Api::V1::BaseController def files if params[:filepath].present? - @result_object = $gitea_hat_client.get_repos_pulls_files_by_owner_repo_index_filepath(@project&.owner.login, @project&.identifier, @pull_request.gitea_number, CGI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}}) + @result_object = $gitea_hat_client.get_repos_pulls_files_by_owner_repo_index_filepath(@project&.owner.login, @project&.identifier, @pull_request.gitea_number, URI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}}) else @result_object = $gitea_hat_client.get_repos_pulls_files_by_owner_repo_index(@project&.owner.login, @project&.identifier, @pull_request.gitea_number, {query: {isNew: "true",token: current_user&.gitea_token, page: page, limit: limit}}) end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ad7acc986..6d1887550 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -309,7 +309,7 @@ class RepositoriesController < ApplicationController api_url = GiteaService.gitea_config[:base_url] tip_exception('不可访问') if params[:filepath].to_s.include?("chinese_dictionary.txt") - url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{CGI.escape(params[:filepath])}?ref=#{CGI.escape(params[:ref])}" + url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{URI.escape(params[:filepath])}?ref=#{URI.escape(params[:ref])}" file_path = [domain, api_url, url].join file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("&") diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index ed5f67212..7e511df93 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -22,7 +22,7 @@ module ProjectsHelper end def render_download_file_url(owner, repository, filepath, ref) - [base_url, "/api/#{owner&.login}/#{repository.identifier}/raw/#{CGI.escape(filepath)}?ref=#{CGI.escape(ref)}"].join + [base_url, "/api/#{owner&.login}/#{repository.identifier}/raw/#{URI.escape(filepath)}?ref=#{URI.escape(ref)}"].join end def render_http_url(project) From bf4ff93ed96c8903fba29aa65125f09f7f6f51ac Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 16:09:15 +0800 Subject: [PATCH 30/31] =?UTF-8?q?fixed=EF=BC=9A=E4=BB=A3=E7=A0=81=E5=9B=9E?= =?UTF-8?q?=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 6d1887550..ad7acc986 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -309,7 +309,7 @@ class RepositoriesController < ApplicationController api_url = GiteaService.gitea_config[:base_url] tip_exception('不可访问') if params[:filepath].to_s.include?("chinese_dictionary.txt") - url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{URI.escape(params[:filepath])}?ref=#{URI.escape(params[:ref])}" + url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{CGI.escape(params[:filepath])}?ref=#{CGI.escape(params[:ref])}" file_path = [domain, api_url, url].join file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("&") From f77b2ae1822da356118e514fe738238f01ee223b Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 16:10:42 +0800 Subject: [PATCH 31/31] =?UTF-8?q?fixed=EF=BC=9A=E4=BB=A3=E7=A0=81=E5=9B=9E?= =?UTF-8?q?=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/projects_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 7e511df93..ed5f67212 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -22,7 +22,7 @@ module ProjectsHelper end def render_download_file_url(owner, repository, filepath, ref) - [base_url, "/api/#{owner&.login}/#{repository.identifier}/raw/#{URI.escape(filepath)}?ref=#{URI.escape(ref)}"].join + [base_url, "/api/#{owner&.login}/#{repository.identifier}/raw/#{CGI.escape(filepath)}?ref=#{CGI.escape(ref)}"].join end def render_http_url(project)