fixed 代码提交日志根据提交commit记录多次

This commit is contained in:
“xxq250” 2022-07-22 10:11:21 +08:00
parent 7793eacf75
commit b21f44b59e
1 changed files with 7 additions and 5 deletions

View File

@ -3,8 +3,6 @@ class CommitLogsController < ApplicationController
def create
tip_exception "未认证" unless params[:token].to_s == "7917908927b6f1b792f2027a08a8b24a2de42c1692c2fd45da0dee5cf90a5af5"
ref = params[:ref]
commit_id = params[:commits][0][:id]
message = params[:commits][0][:message]
user_name = params[:pusher][:login]
user_mail = params[:pusher][:email]
user = User.find_by(mail: user_mail)
@ -17,9 +15,13 @@ class CommitLogsController < ApplicationController
owner = User.find_by(login: owner_name)
project = Project.where(identifier: repository_name).where(user_id: owner&.id)&.first
project = Project.where(identifier: repository_name).where(gpid: repository_id)&.first if project.blank?
CommitLog.create(user: user, project: project, repository_id: repository_id,
name: repository_name, full_name: repository_full_name,
ref: ref, commit_id: commit_id, message: message)
params[:commits].each do |commit|
commit_id = commit[:id]
message = commit[:message]
CommitLog.create(user: user, project: project, repository_id: repository_id,
name: repository_name, full_name: repository_full_name,
ref: ref, commit_id: commit_id, message: message)
end
end
end