From b21f44b59efe0e8b16f95ffd8bf2b3e8408f5daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Fri, 22 Jul 2022 10:11:21 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=A0=B9=E6=8D=AE=E6=8F=90=E4=BA=A4commit?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=A4=9A=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/commit_logs_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/commit_logs_controller.rb b/app/controllers/commit_logs_controller.rb index c02d199b0..c62c13000 100644 --- a/app/controllers/commit_logs_controller.rb +++ b/app/controllers/commit_logs_controller.rb @@ -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