mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-22 12:45:46 +08:00
Merge branch 'pre_trustie_server' into trustie_server
This commit is contained in:
@@ -46,7 +46,7 @@ class Api::V1::Issues::JournalsController < Api::V1::BaseController
|
||||
end
|
||||
|
||||
def load_issue
|
||||
@issue = @project.issues.issue_issue.where(project_issues_index: params[:index]).where.not(id: params[:index]).take || Issue.find_by_id(params[:index])
|
||||
@issue = @project.issues.issue_issue.where(project_issues_index: params[:index]).where.not(id: params[:index]).take || @project.issues.issue_issue.find_by_id(params[:index])
|
||||
if @issue.blank?
|
||||
render_not_found("疑修不存在!")
|
||||
end
|
||||
|
||||
@@ -70,7 +70,7 @@ class Api::V1::IssuesController < Api::V1::BaseController
|
||||
private
|
||||
|
||||
def load_issue
|
||||
@issue = @project.issues.issue_issue.where(project_issues_index: params[:index]).where.not(id: params[:index]).take || Issue.find_by_id(params[:index])
|
||||
@issue = @project.issues.issue_issue.where(project_issues_index: params[:index]).where.not(id: params[:index]).take || @project.issues.issue_issue.find_by_id(params[:index])
|
||||
if @issue.blank?
|
||||
render_not_found("疑修不存在!")
|
||||
end
|
||||
|
||||
@@ -26,6 +26,16 @@ class CommitLogsController < ApplicationController
|
||||
commit_log.project_trends.create(user_id: user.id, project_id: project&.id, action_type: "create") if user.id !=2
|
||||
# 统计数据新增
|
||||
CacheAsyncSetJob.perform_later("project_common_service", {commits: 1}, project.id)
|
||||
|
||||
commit_user = User.find_by(mail: commit[:committer][:email]) rescue nil
|
||||
commit_user = User.find_by(login: commit[:committer][:name]) if commit_user.blank? rescue nil
|
||||
next if commit_user.blank?
|
||||
|
||||
# 触发变更issue状态的job
|
||||
close_issue_content = message.to_s.scan(/\b(Close|Closes|Closed|Closing|close|closes|closed|closing)\s*(#\d+(,\s*#\d+)*)?\b/)
|
||||
ChangeIssueStatusByMessageJob.perform_later(commit_id, project, commit_user, close_issue_content[0][1], 5) if close_issue_content[0].present? && close_issue_content[0][1].present?
|
||||
solve_issue_content = message.to_s.scan(/\b(Fix|Fixes|Fixed|Fixing|fix|fixes|fixed|fixing|Resolve|Resolves|Resolved|Resolving|resolve|resolves|resolved|resolving|Implement|Implements|Implemented|Implementing|implement|implements|implemented|implementing)\s*(#\d+(,\s*#\d+)*)?\b/)
|
||||
ChangeIssueStatusByMessageJob.perform_later(commit_id, project, commit_user, solve_issue_content[0][1], 3) if solve_issue_content[0].present? && solve_issue_content[0][1].present?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -77,4 +77,12 @@ module GitHelper
|
||||
cha_path = path.present? ? path.split(";") : []
|
||||
cha_path.reject(&:blank?)[0].try(:strip)
|
||||
end
|
||||
|
||||
def expain_issue_commit(commit_message)
|
||||
respace_arr= commit_message.to_s.scan(/#(\d+)/).map{|s|[s[0], "##{s[0]}"]}.uniq.sort_by{|s|-s[0].to_i}
|
||||
respace_arr.each do |item|
|
||||
issue = Issue.find_by_id(item[0].to_i)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -50,7 +50,7 @@ class MarkFilesController < ApplicationController
|
||||
end
|
||||
|
||||
def load_pull_request
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || PullRequest.find_by_id(params[:id])
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || @project.pull_requests.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
53
app/controllers/oauth/ci4s_controller.rb
Normal file
53
app/controllers/oauth/ci4s_controller.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
class Oauth::Ci4sController < Oauth::BaseController
|
||||
include RegisterHelper
|
||||
|
||||
|
||||
def oauth_url
|
||||
redirect_to Ci4s::Service.oauth_url
|
||||
end
|
||||
|
||||
# 需要educoder那边设置回调地址
|
||||
def create
|
||||
begin
|
||||
code = params['code'].to_s.strip
|
||||
tip_exception("code不能为空") if code.blank?
|
||||
|
||||
new_user = false
|
||||
token = Ci4s::Service.access_token(code)
|
||||
Rails.logger.info("[OAuth2] result -> #{token}")
|
||||
result = Ci4s::Service.user_info(token[:access_token])
|
||||
tip_exception("请求用户信息错误") if result['code'].to_i != 200
|
||||
user_info = result['data']
|
||||
# 存在该用户
|
||||
open_user = OpenUsers::Ci4s.find_by(uid: user_info['username'])
|
||||
if open_user.present? && open_user.user.present?
|
||||
successful_authentication(open_user.user)
|
||||
redirect_to root_path(new_user: false)
|
||||
return
|
||||
else
|
||||
if current_user.blank? || !current_user.logged?
|
||||
new_user = true
|
||||
session[:unionid] = user_info['username']
|
||||
# login = User.generate_login('E')
|
||||
login = user_info['username']
|
||||
email = user_info['email']
|
||||
email = "#{login}@forge.com" if email.blank?
|
||||
reg_result = autologin_register(login, email, "Ec#{login}2021#", 'educoder', user_info['mobile'])
|
||||
Rails.logger.info("[OAuth2] reg_result -> #{reg_result}")
|
||||
if reg_result[:message].blank?
|
||||
open_user = OpenUsers::Ci4s.create!(user_id: reg_result[:user][:id], uid: login, extra: user_info)
|
||||
successful_authentication(open_user.user)
|
||||
else
|
||||
tip_exception(reg_result[:message])
|
||||
end
|
||||
else
|
||||
OpenUsers::Ci4s.create!(user: current_user, uid: user_info['username'], extra: user_info)
|
||||
end
|
||||
end
|
||||
Rails.logger.info("[OAuth2] session[:unionid] -> #{session[:unionid]}")
|
||||
redirect_to root_path(new_user: new_user)
|
||||
rescue Exception => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -296,11 +296,11 @@ class PullRequestsController < ApplicationController
|
||||
|
||||
private
|
||||
def load_pull_request
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || PullRequest.find_by_id(params[:id])
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || @project.pull_requests.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
def find_pull_request
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || PullRequest.find_by_id(params[:id])
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || @project.pull_requests.find_by_id(params[:id])
|
||||
@issue = @pull_request&.issue
|
||||
if @pull_request.blank?
|
||||
normal_status(-1, "合并请求不存在")
|
||||
|
||||
@@ -14,7 +14,7 @@ class ReviewsController < ApplicationController
|
||||
end
|
||||
|
||||
def load_pull_request
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || PullRequest.find_by_id(params[:id])
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || @project.pull_requests.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user