<%=link_to "代码统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %>
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index b1936e19b..f43b87360 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -304,7 +304,7 @@
<% if ma.course_message.parent_id.nil? %>
@@ -423,7 +423,7 @@
From 51b630666fcccc146c5390fc0f64c88195228bfa Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Fri, 2 Dec 2016 13:20:46 +0800
Subject: [PATCH 6/7] =?UTF-8?q?=E8=BF=98=E5=8E=9Fpullrequest=E6=B3=A8?=
=?UTF-8?q?=E9=87=8A=E7=9A=84=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/pull_requests_controller.rb | 5 ++---
app/views/repositories/show.html.erb | 20 ++++++++++----------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb
index 7da5a0dc1..a1a085895 100644
--- a/app/controllers/pull_requests_controller.rb
+++ b/app/controllers/pull_requests_controller.rb
@@ -228,11 +228,9 @@ class PullRequestsController < ApplicationController
def update_pull_request
begin
@g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state])
-
- # 自己关闭/重新打开 就给每个管理员发送消息,如果是管理员关闭/重新打开,就给用户发消息
request = @g.merge_request(@project.gpid, params[:id])
@project_member = Member.where(:project_id => @project.id)
- # 发送消息
+ # 自己关闭/重新打开 就给每个管理员发送消息
if ( params[:state] == "close" || params[:state] == "reopen" ) && User.current.login == request.author.try(:username)
unless @project_member.nil?
@project_member.each do |mem|
@@ -242,6 +240,7 @@ class PullRequestsController < ApplicationController
end
end
end
+ # 如果是管理员关闭/重新打开,就给用户发消息
if ( params[:state] == "close" || params[:state] == "reopen" ) && User.current.login != request.author.try(:username)
message_user = User.where( :login => request.author.try(:username) ).first
send_message(message_user.id, @project.id, request.id, params[:state] == "close" ? 4 : 3)
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 05b8d40d0..282df48c3 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -27,17 +27,17 @@
<% unless @entries.nil? %>
ZIP下载
- <%# if User.current.member_of?(@project) && @project.is_public? %>
- <%# if quality_analysis(User.current.try(:login), @repository.id).nil? %>
- <%#= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "1"), :remote => true, :class => "btn_zipdown fr" %>
- <%# else %>
- <%#= link_to "重新分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "2"), :remote => true, :class => "btn_zipdown fr" %>
- <%# end %>
- <%# end %>
+ <% if User.current.member_of?(@project) && @project.is_public? %>
+ <% if quality_analysis(User.current.try(:login), @repository.id).nil? %>
+ <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "1"), :remote => true, :class => "btn_zipdown fr" %>
+ <% else %>
+ <%= link_to "重新分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "2"), :remote => true, :class => "btn_zipdown fr" %>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %>
+ <%= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %>
<% end %>
- <%# unless QualityAnalysis.where(:project_id => @project.id).first.nil? %>
- <%#= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %>
- <%# end %>
<%=link_to "代码统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %>
From 4acb674d43fb1baa99dd45097d3df59cffcdf259 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 2 Dec 2016 14:42:52 +0800
Subject: [PATCH 7/7] =?UTF-8?q?pull=20request=20=E5=8F=91=E9=80=81?=
=?UTF-8?q?=E6=B6=88=E6=81=AF=E4=BB=A3=E7=A0=81=E9=87=8D=E6=9E=84=EF=BC=8C?=
=?UTF-8?q?=E5=B0=81=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/pull_requests_controller.rb | 77 +++++++++------------
1 file changed, 32 insertions(+), 45 deletions(-)
diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb
index 0a0a422a6..b68db3563 100644
--- a/app/controllers/pull_requests_controller.rb
+++ b/app/controllers/pull_requests_controller.rb
@@ -101,29 +101,14 @@ class PullRequestsController < ApplicationController
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id)
@fork_project_name = Project.find(params[:target_project_id]).try(:name)
@fork_pr_message = true if @fork_project_name
- # fork项目的pullrequest发送消息
# 向管理员发送消息
- @project_member = Member.where(:project_id => params[:target_project_id].to_i)
- unless @project_member.nil?
- @project_member.each do |mem|
- if is_project_manager?(mem.user_id, params[:target_project_id].to_i) && mem.user_id != User.current.id
- send_message(mem.user_id, params[:target_project_id].to_i, request.id, 1)
- end
- end
- end
- # 创建Trustie数据
+ send_message_to_manager(params[:target_project_id].to_i, request.id, 1)
PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id, :title => title)
else
@project_member = Member.where(:project_id => @project.id)
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
# 发送消息
- unless @project_member.nil?
- @project_member.each do |mem|
- if is_project_manager?(mem.user_id, @project.id) && mem.user_id != User.current.id
- send_message(mem.user_id, @project.id, request.id, 1)
- end
- end
- end
+ send_message_to_manager(@project.id, request.id, 1)
# 创建Trustie数据
PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id, :title => title)
respond_to do |format|
@@ -204,14 +189,8 @@ class PullRequestsController < ApplicationController
def accept_pull_request
begin
status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
- PullRequest.create(:pull_request_id => status.id, :user_id => User.current.id, :gpid => status.project_id)
-
# 接受后,给用户发消息
- request = @g.merge_request(@project.gpid, params[:id])
- if User.current.login != request.author.try(:username)
- message_user = User.where( :login => request.author.try(:username) ).first
- send_message(message_user.id, @project.id, request.id, 2)
- end
+ send_message_to_author(@project.id, status.author.try(:user_name), params[:id], 2)
respond_to do |format|
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
@@ -237,25 +216,13 @@ class PullRequestsController < ApplicationController
# @return [Gitlab::ObjectifiedHash] Information about updated merge request.
def update_pull_request
begin
- @g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state])
- request = @g.merge_request(@project.gpid, params[:id])
- @project_member = Member.where(:project_id => @project.id)
- # 自己关闭/重新打开 就给每个管理员发送消息
- if ( params[:state] == "close" || params[:state] == "reopen" ) && User.current.login == request.author.try(:username)
- unless @project_member.nil?
- @project_member.each do |mem|
- if is_project_manager?(mem.user_id, @project.id) && mem.user_id != User.current.id
- send_message(mem.user_id, @project.id, request.id, params[:state] == "close" ? 4 : 3)
- end
- end
- end
+ request = @g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state])
+ user = User.find_by_login(request.author.try(:username))
+ status = params[:state] == "close" ? 4 : 3
+ send_message_to_manager(@project.id, params[:id], status)
+ if !is_project_manager?(user.id, @project.id)
+ send_message_to_author(@project, user.login, request.id, status)
end
- # 如果是管理员关闭/重新打开,就给用户发消息
- if ( params[:state] == "close" || params[:state] == "reopen" ) && User.current.login != request.author.try(:username)
- message_user = User.where( :login => request.author.try(:username) ).first
- send_message(message_user.id, @project.id, request.id, params[:state] == "close" ? 4 : 3)
- end
-
respond_to do |format|
format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)}
end
@@ -361,9 +328,29 @@ class PullRequestsController < ApplicationController
end
end
- def send_message user_id, project_id, pull_request_id, status
- ForgeMessage.create(:user_id => user_id, :project_id => project_id,
- :forge_message_id => pull_request_id, :forge_message_type => "PullRequest", :viewed => true, :status => status)
+ def send_message_to_manager project_id, pull_request_id, status
+ project = Project.find(project_id)
+ project.members.each do |member|
+ if is_project_manager?(member.user_id, project_id) && User.current.id != member.user_id
+ add_message(member.user_id, project_id, pull_request_id, status)
+ end
+ end
+ end
+
+ def send_message_to_author(project_id, user_login, request_id, status)
+ user = get_user_by_login_and(user_login)
+ if user.id != User.current.id
+ add_message(user.id, project_id, request_id, status)
+ end
+ end
+
+ def add_message(user_id, project_id, pull_request_id, status)
+ ForgeMessage.create(:user_id => user_id,
+ :project_id => project_id,
+ :forge_message_id => pull_request_id,
+ :forge_message_type => "PullRequest",
+ :viewed => true,
+ :status => status)
end
def authorize_logged