Merge branch 'standalone_develop' into trustie_server

This commit is contained in:
xxq250 2023-05-08 15:36:58 +08:00
commit e6b3634b40
4 changed files with 25 additions and 8 deletions

View File

@ -217,6 +217,21 @@ class RepositoriesController < ApplicationController
end
end
def replace_file
#删除
delete_interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, params[:delete_file].merge(identifier: @project.identifier))
return render_error(delete_interactor.error) unless delete_interactor.success?
#新建
interactor = Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params)
if interactor.success?
@file = interactor.result
render_result(0, "替换成功")
else
render_error(interactor.error)
end
end
def delete_file
interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, params.merge(identifier: @project.identifier))
if interactor.success?

View File

@ -10,6 +10,7 @@ module CustomRegexp
IP = /^((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/
URL_REGEX = /\A(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?\z/i
REPOSITORY_NAME_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9\-\_\.]+[a-zA-Z0-9]$/ #只含有数字、字母、下划线不能以下划线开头和结尾
# REPOSITORY_NAME_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9\-\_\.]+[a-zA-Z0-9]$/ #只含有数字、字母、下划线不能以下划线开头和结尾
REPOSITORY_NAME_REGEX = /^[a-zA-Z0-9\-\_\.]+[a-zA-Z0-9]$/ #只含有数字、字母、下划线不能以下划线开头和结尾
MD_REGEX = /^.+(\.[m|M][d|D])$/
end

View File

@ -1,19 +1,19 @@
user = $redis_cache.hgetall("v2-owner-common:#{contributor["name"]}-#{contributor["email"]}")
user = $redis_cache.hgetall("v2-owner-common:#{contributor["name"] || contributor["login"]}-#{contributor["email"]}")
if user.blank?
json.contributions contributor["commits"]
json.contributions contributor["commits"] || contributor["contributions"]
json.login nil
json.type nil
json.name contributor["name"].downcase
json.name (contributor["name"] || contributor["login"]).to_s.downcase
json.email contributor["email"]
json.image_url User::Avatar.get_letter_avatar_url(contributor["name"])
json.contribution_perc User.new(login: contributor["name"], mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"])
json.image_url User::Avatar.get_letter_avatar_url(contributor["name"] || contributor["login"])
json.contribution_perc User.new(login: (contributor["name"] || contributor["login"]), mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"])
else
json.contributions contributor["commits"]
json.contributions contributor["commits"] || contributor["contributions"]
json.id user["id"]
json.login user["login"]
json.email user["email"]
json.type user["type"]
json.name user["name"].downcase
json.name (user["name"] || contributor["name"] || contributor["login"]).to_s.downcase
json.image_url user["avatar_url"]
db_user = User.find_by_id(user["id"])
json.contribution_perc db_user.simple_contribution_perc(project, contributor["contribution_perc"]) if db_user.present?

View File

@ -526,6 +526,7 @@ Rails.application.routes.draw do
get :tags
get :contributors
post :create_file
post :replace_file
put :update_file
delete :delete_file
post :repo_hook