From 920e470f6d487764a3480d5eb053b712020fdc01 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 5 Aug 2016 17:51:39 +0800 Subject: [PATCH 01/36] =?UTF-8?q?pull=20request=E5=88=97=E8=A1=A8=E7=9C=81?= =?UTF-8?q?=E7=95=A5=E5=8F=B7=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pull_requests/_pull_requests_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/pull_requests/_pull_requests_list.html.erb b/app/views/pull_requests/_pull_requests_list.html.erb index db9059710..e32940ca3 100644 --- a/app/views/pull_requests/_pull_requests_list.html.erb +++ b/app/views/pull_requests/_pull_requests_list.html.erb @@ -4,7 +4,7 @@ <% @requests.each do |request| %>
  • <% request %> - <%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%> + <%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl hidden", :style => "width:100%;"%>
    由 <%= link_to request.author.try(:username), user_path(get_user_by_login_and(request.author.try(:username))), :class => "link-blue" %> 创建于<%= time_tag(request.created_at) %> From 518d6bacbeef22ba7cb5a8be5b5800a668fbe156 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 8 Aug 2016 15:23:55 +0800 Subject: [PATCH 02/36] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=B3=E9=97=ADpull?= =?UTF-8?q?=20request=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 14 +++++++++++++- app/helpers/pull_requests_helper.rb | 11 +++++++++++ app/views/pull_requests/_show.html.erb | 6 ++++-- config/locales/projects/zh.yml | 7 ++++++- config/routes.rb | 1 + 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 58d1cb3b2..c365a8b37 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -1,7 +1,7 @@ class PullRequestsController < ApplicationController before_filter :find_project_and_repository - before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new] + before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request] layout "base_projects" include PullRequestsHelper include ApplicationHelper @@ -107,6 +107,18 @@ class PullRequestsController < ApplicationController end end + # 更新请求的状态state => cloesed + def update_pull_request + begin + @g.update_merge_request(@project.gpid, params[:id], :state_event => params[:state]) + respond_to do |format| + format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} + end + rescue Exception => e + @message = e.message + end + end + # 获取某次请求的提交次数 def pull_request_commits @type = parms[:type] diff --git a/app/helpers/pull_requests_helper.rb b/app/helpers/pull_requests_helper.rb index 82d4edc0f..c33100ea8 100644 --- a/app/helpers/pull_requests_helper.rb +++ b/app/helpers/pull_requests_helper.rb @@ -14,4 +14,15 @@ module PullRequestsHelper User.find(user_id).try(:login) end + def get_state state + case state + when "open","reopened" + l(:label_state_open) + when "closed" + l(:label_state_closed) + when "merged" + l(:label_state_merged) + end + end + end diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index 7bcf296a3..bb3cefc9f 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -4,8 +4,10 @@
    - <%= @request.state == "merged" ? "已合并" : "待处理" %>合并请求 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %> - + <%= get_state(@request.state) %>合并请求 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %> + <% unless @request.state == "merged" %> + <%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %> + <% end %>
    <%= @request.title %>

    <%= @request.description %>

    diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 91cc96791..792ff35fd 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -456,4 +456,9 @@ zh: # 版本库迁移 label_repository_migrate_dec: 注意:Trustie版本库近期进行了一次大的改造,历史版本需要转换成新的版本,输入新的版本库名,即可完成转换。 转换过程可能需要等待一段时间。 - label_repository_name_dec: 版本库名仅小写字母(a-z)、数字、破折号(-)和下划线(_)可以使用,长度必须在 1 到 254 个字符之间,一旦保存,标识无法修改。 \ No newline at end of file + label_repository_name_dec: 版本库名仅小写字母(a-z)、数字、破折号(-)和下划线(_)可以使用,长度必须在 1 到 254 个字符之间,一旦保存,标识无法修改。 + + # pull requests + label_state_open: 待处理 + label_state_closed: 关闭 + label_state_merged: 已合并 diff --git a/config/routes.rb b/config/routes.rb index 5527212fd..eb822d27e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -816,6 +816,7 @@ RedmineApp::Application.routes.draw do get 'accept_pull_request' get 'pull_request_commits' get 'pull_request_changes' + get 'update_pull_request' end end From 53dd41ec37fe9592e11b5d297199b356f691923a Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 8 Aug 2016 16:33:39 +0800 Subject: [PATCH 03/36] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=95=99=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pull_requests/_show.html.erb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index b3d6dd314..e1d54dce4 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -4,7 +4,7 @@
    - <%= @request.state == "merged" ? "已合并" : "待处理" %>合并请求 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %> + <%= @request.state == "merged" ? "已合并" : "待处理" %>合并请求 由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %> 于 <%= time_tag(@request.created_at) %> 提交 · 最后编辑时间 <%= time_tag(@request.updated_at) %>
    @@ -25,14 +25,18 @@
      -
    • <%= link_to "提交#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %>
    • +
    • <%= link_to "留言#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 0), :remote => true, :class => "active" %>
    • +
    • <%= link_to "提交#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true %>
    • <%= link_to "改动#{@changes_count}".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %>
    根据最近提交时间排列
    - <%= render :partial => "pull_requests/pull_request_commits" %> + 留言
    + <%= render :partial => "pull_requests/pull_request_commits" %> +
    +
    <%= render :partial => "pull_requests/pull_request_changes" %>
    <% end %> @@ -54,7 +58,7 @@ var index = $(".merge-record li a").index(this); - $("#merge_record_0, #merge_record_1").hide(); + $("#merge_record_0, #merge_record_1,#merge_record_2").hide(); $("#merge_record_" + index).show(); }); \ No newline at end of file From d1b4e83fee2e5a22de0c6d412444ee941933c27d Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 9 Aug 2016 10:29:18 +0800 Subject: [PATCH 04/36] =?UTF-8?q?=E5=AE=8C=E6=88=90pull=20request=20?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 5 ++++- app/views/pull_requests/index.html.erb | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index c365a8b37..7233bdfe7 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -14,9 +14,12 @@ class PullRequestsController < ApplicationController @requests = @g.merge_requests(@project.gpid).select{|request| request.state == "opened" || request.state == "reopened"} when "2" @requests = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"} + when "3" + @requests = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"} end @requests_opened_count = @requests.count - @requests_merged_count = params[:type] ? @requests.count : @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count + @requests_merged_count = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count + @requests_closed_count = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}.count respond_to do |format| format.html format.js diff --git a/app/views/pull_requests/index.html.erb b/app/views/pull_requests/index.html.erb index f9f7fe4db..23ca13178 100644 --- a/app/views/pull_requests/index.html.erb +++ b/app/views/pull_requests/index.html.erb @@ -2,6 +2,7 @@
    • <%= link_to "待处理#{@requests_opened_count}".html_safe, project_pull_requests_path(:type => "1"), :remote => true %>
    • <%= link_to "已处理#{@requests_merged_count}".html_safe, project_pull_requests_path(:type => "2"), :remote => true %>
    • +
    • <%= link_to "已关闭#{@requests_closed_count}".html_safe, project_pull_requests_path(:type => "3"), :remote => true %>
    • <%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
      From 5dd6244a347b506d8c1b1fe8286f9fe38125f5f0 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 9 Aug 2016 10:45:14 +0800 Subject: [PATCH 05/36] =?UTF-8?q?pull=20request=E6=B7=BB=E5=8A=A0=E7=95=99?= =?UTF-8?q?=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_pull_request_commits.html.erb | 3 +- app/views/pull_requests/_show.html.erb | 32 ++++++++++++------- public/stylesheets/css/project.css | 7 +++- public/stylesheets/css/structure.css | 1 + 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/app/views/pull_requests/_pull_request_commits.html.erb b/app/views/pull_requests/_pull_request_commits.html.erb index a7f6b5aa7..b7b47ede2 100644 --- a/app/views/pull_requests/_pull_request_commits.html.erb +++ b/app/views/pull_requests/_pull_request_commits.html.erb @@ -1,9 +1,10 @@ +
      根据最近提交时间排列
      <% @commits.each do |commit| %>
      <%= format_date(commit.created_at) %> -

      <%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %>创建于<%= time_tag(commit.created_at) %>前

      +

      <%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %> 创建于<%= time_tag(commit.created_at) %>前

      <%= commit.title %> diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index bb3cefc9f..ce0c633c6 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -4,7 +4,7 @@
      - <%= get_state(@request.state) %>合并请求 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %> + <%= get_state(@request.state) %>合并请求 由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %> 于 <%= time_tag(@request.created_at) %> 前提交 · 最后编辑时间 <%= time_tag(@request.updated_at) %> 前 <% unless @request.state == "merged" %> <%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %> <% end %> @@ -36,14 +36,30 @@
        -
      • <%= link_to "提交#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %>
      • +
      • <%= link_to "留言#{@commits_count}".html_safe, :class => "active" %>
      • +
      • <%= link_to "提交#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true %>
      • <%= link_to "改动#{@changes_count}".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %>
      -
      根据最近提交时间排列
      - <%= render :partial => "pull_requests/pull_request_commits" %> +
      + Hjqreturn20小时前 +
      +
      回复内容
      +
      +
      + Hjqreturn20小时前 +
      +
      已关闭请求/重新审核请求
      +
      +
      + + 提 交 +
      + <%= render :partial => "pull_requests/pull_request_commits" %> +
      +
      <%= render :partial => "pull_requests/pull_request_changes" %>
      <% end %> @@ -53,19 +69,13 @@ \ No newline at end of file diff --git a/public/stylesheets/css/project.css b/public/stylesheets/css/project.css index 4c4019593..3653cf799 100644 --- a/public/stylesheets/css/project.css +++ b/public/stylesheets/css/project.css @@ -540,4 +540,9 @@ a:hover.upload_btn_grey{background:#8a8a8a;} .merge-commit-code {width:150px; float:left; text-align:right;} .merge-show {margin:-10px -10px 0 -10px; padding:10px; line-height:36px; border-bottom:1px solid #ddd;} .open-status {color:#fff; padding:0 16px; background-color:#3b94d6; border-radius:2px; display:inline-block;} -.merge-commit-option {padding:12px; border:1px solid #ddd; background-color:#f9f9f9; border-radius:2px;} \ No newline at end of file +.merge-commit-option {padding:12px; border:1px solid #ddd; background-color:#f9f9f9; border-radius:2px;} +.merge-discussion-content {font-size:13px; color: #484848; margin:0 -10px; padding:10px; border-bottom:1px solid #ddd;} +.merge-discussion-detail {font-size:13px; line-height:1.5em; color:#484848; margin-top:10px;} +.merge-discussion-automatic {background-color:#fdfdfd;} +.merge-discussion-input {margin:0 -10px; padding:10px; background-color:#f8f8f8;} +.merge-discussion-input textarea {width:720px; height:80px; font-size:13px; line-height:16px; color:#484848; margin-bottom:10px; padding:5px;} \ No newline at end of file diff --git a/public/stylesheets/css/structure.css b/public/stylesheets/css/structure.css index 44b1165c6..c9a4059e0 100644 --- a/public/stylesheets/css/structure.css +++ b/public/stylesheets/css/structure.css @@ -474,6 +474,7 @@ a.f_grey:hover {color:#000000;} .shadowbox_news_list{ max-height:400px; overflow:hidden;} .shadowbox_news_list a{ color:#999;} .shadowbox_news_list li{ height:40px; border-bottom:1px dashed #ebebeb; line-height:40px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; padding:0 10px;} +.shadowbox_news_list li:last-child {border-bottom:none;} .shadowbox_news_list li:hover{ background-color:#eee;} span.shadowbox_news_user{ color:#3b94d6;} a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; color:#3b94d6; text-align:center;border-top:1px solid #eee;} From 6319a1bac6236f3570f5aa8fefec07f6aec6429f Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 9 Aug 2016 10:53:44 +0800 Subject: [PATCH 06/36] =?UTF-8?q?PR=E6=B7=BB=E5=8A=A0=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 68 ++++++++++++++++++--- config/routes.rb | 1 + 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 7233bdfe7..8d11e7279 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -110,7 +110,20 @@ class PullRequestsController < ApplicationController end end - # 更新请求的状态state => cloesed + # Updates a merge request. + # + # @example + # Gitlab.update_merge_request(5, 42, :title => 'New title') + # + # @param [Integer] project The ID of a project. + # @param [Integer] id The ID of a merge request. + # @param [Hash] options A customizable set of options. + # @option options [String] :title The title of a merge request. + # @option options [String] :source_branch The source branch name. + # @option options [String] :target_branch The target branch name. + # @option options [Integer] :assignee_id The ID of a user to assign merge request. + # @option options [String] :state_event New state (close|reopen|merge). + # @return [Gitlab::ObjectifiedHash] Information about updated merge request. def update_pull_request begin @g.update_merge_request(@project.gpid, params[:id], :state_event => params[:state]) @@ -122,16 +135,57 @@ class PullRequestsController < ApplicationController end end - # 获取某次请求的提交次数 + # Creates a merge request. + # + # @example + # Gitlab.create_merge_request(5, 'New merge request', + # :source_branch => 'source_branch', :target_branch => 'target_branch') + # Gitlab.create_merge_request(5, 'New merge request', + # :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42) + def create_pull_request_comment + content = params[:content] + begin + @comments = @g.create_merge_request_comment(@project.gpid, params[:id], content) + rescue Exception => e + @message = e.message + end + end + + # Gets the comments on a merge request. + # + # @example + # Gitlab.merge_request_comments(5, 1) + def pull_request_comments + begin + @comments = @g.merge_request_comments(@project.gpid, params[:id]) + rescue Exception => e + @message = e.message + end + end + + # Get a list of merge request commits. + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - The ID of MR def pull_request_commits - @type = parms[:type] - @commits = @g.merge_request_commits(@project.gpid, params[:id].to_i) + begin + @commits = @g.merge_request_commits(@project.gpid, params[:id]) + rescue Exception => e + @message = e.message + end end - # 获取某次请求的改动 + # Shows information about the merge request including its files and changes. With GitLab 8.2 the return fields upvotes and downvotes are deprecated and always return 0. + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - The ID of MR def pull_request_changes - @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) - @changes_count = @changes.count + begin + @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) + @changes_count = @changes.count + rescue Exception => e + @message = e.message + end end private diff --git a/config/routes.rb b/config/routes.rb index eb822d27e..b50ee9c65 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -817,6 +817,7 @@ RedmineApp::Application.routes.draw do get 'pull_request_commits' get 'pull_request_changes' get 'update_pull_request' + get 'pull_request_comments' end end From b7bccc7d227b22e83c99b8c911e540e439510919 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 9 Aug 2016 14:00:36 +0800 Subject: [PATCH 07/36] =?UTF-8?q?PR=E6=B7=BB=E5=8A=A0=E8=AF=84=E8=AE=BA=20?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 5 +++- .../_pull_request_comments.html.erb | 19 +++++++++++++ app/views/pull_requests/_show.html.erb | 27 +++++-------------- .../pull_requests/pull_request_changes.js.erb | 2 +- .../pull_request_comments.js.erb | 1 + .../pull_requests/pull_request_commits.js.erb | 2 +- 6 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 app/views/pull_requests/_pull_request_comments.html.erb create mode 100644 app/views/pull_requests/pull_request_comments.js.erb diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 8d11e7279..f63f1dc17 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -1,7 +1,7 @@ class PullRequestsController < ApplicationController before_filter :find_project_and_repository - before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request] + before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request, :pull_request_comments] layout "base_projects" include PullRequestsHelper include ApplicationHelper @@ -87,6 +87,8 @@ class PullRequestsController < ApplicationController @commits_count = @commits.count @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) @changes_count = @changes.count + @comments = @g.merge_request_comments(@project.gpid, params[:id]) + @comments_count = @comments.count end # Accept a merge request. @@ -170,6 +172,7 @@ class PullRequestsController < ApplicationController def pull_request_commits begin @commits = @g.merge_request_commits(@project.gpid, params[:id]) + @commits_count = @commits.count rescue Exception => e @message = e.message end diff --git a/app/views/pull_requests/_pull_request_comments.html.erb b/app/views/pull_requests/_pull_request_comments.html.erb new file mode 100644 index 000000000..e5fa3a052 --- /dev/null +++ b/app/views/pull_requests/_pull_request_comments.html.erb @@ -0,0 +1,19 @@ + + + + + +<% @comments.each do |comment| %> +
      + <%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %> + <%#= time_tag(comment.author.try(:created_at)) %>前 +
      +
      <%= comment.note %>
      +
      +<% end %> + +
      + + + 提 交 +
      \ No newline at end of file diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index ce0c633c6..31d337faf 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -7,13 +7,13 @@ <%= get_state(@request.state) %>合并请求 由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %> 于 <%= time_tag(@request.created_at) %> 前提交 · 最后编辑时间 <%= time_tag(@request.updated_at) %> 前 <% unless @request.state == "merged" %> <%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %> - <% end %> + <% end %>
      <%= @request.title %>

      <%= @request.description %>

      +
      请求将 <%= @request.source_branch %> 合并至 <%= @request.target_branch %> - <% if @commits_count == 0 && @changes_count == 0 %>
      <%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %>
      @@ -33,28 +33,15 @@
      <% end %> <% end %> -
      +
        -
      • <%= link_to "留言#{@commits_count}".html_safe, :class => "active" %>
      • -
      • <%= link_to "提交#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true %>
      • -
      • <%= link_to "改动#{@changes_count}".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %>
      • +
      • <%= link_to "留言#{@comments_count}".html_safe, pull_request_comments_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "active" %>
      • +
      • <%= link_to "提交#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true %>
      • +
      • <%= link_to "改动#{@changes_count}".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true %>
      -
      - Hjqreturn20小时前 -
      -
      回复内容
      -
      -
      - Hjqreturn20小时前 -
      -
      已关闭请求/重新审核请求
      -
      -
      - - 提 交 -
      + <%= render :partial => "pull_requests/pull_request_comments" %>
      <%= render :partial => "pull_requests/pull_request_commits" %> diff --git a/app/views/pull_requests/pull_request_changes.js.erb b/app/views/pull_requests/pull_request_changes.js.erb index 2b3d77537..d1cf90c2f 100644 --- a/app/views/pull_requests/pull_request_changes.js.erb +++ b/app/views/pull_requests/pull_request_changes.js.erb @@ -1 +1 @@ -$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>'); \ No newline at end of file +$("#merge_record_2").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>'); \ No newline at end of file diff --git a/app/views/pull_requests/pull_request_comments.js.erb b/app/views/pull_requests/pull_request_comments.js.erb new file mode 100644 index 000000000..5a7e6683c --- /dev/null +++ b/app/views/pull_requests/pull_request_comments.js.erb @@ -0,0 +1 @@ +$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_comments") %>'); \ No newline at end of file diff --git a/app/views/pull_requests/pull_request_commits.js.erb b/app/views/pull_requests/pull_request_commits.js.erb index 0833b1e8a..217198291 100644 --- a/app/views/pull_requests/pull_request_commits.js.erb +++ b/app/views/pull_requests/pull_request_commits.js.erb @@ -1 +1 @@ -$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>'); \ No newline at end of file +$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>'); \ No newline at end of file From 87c5f5054501dacac6d3d3dfaeb9cedc39c89e8d Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 9 Aug 2016 14:51:48 +0800 Subject: [PATCH 08/36] =?UTF-8?q?PULL=20request=20=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=8F=8A=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 8 +++- .../_pull_request_comments.html.erb | 42 ++++++++++++++----- .../pull_requests/pull_request_changes.js.erb | 2 +- .../pull_requests/pull_request_commits.js.erb | 2 +- config/routes.rb | 1 + public/stylesheets/css/project.css | 2 +- 6 files changed, 42 insertions(+), 15 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index f63f1dc17..7dc6b7b53 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -1,7 +1,8 @@ class PullRequestsController < ApplicationController before_filter :find_project_and_repository - before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request, :pull_request_comments] + before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, + :update_pull_request, :pull_request_comments, :create_pull_request_comment] layout "base_projects" include PullRequestsHelper include ApplicationHelper @@ -145,9 +146,12 @@ class PullRequestsController < ApplicationController # Gitlab.create_merge_request(5, 'New merge request', # :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42) def create_pull_request_comment - content = params[:content] + content = params[:pull_request_comment] begin @comments = @g.create_merge_request_comment(@project.gpid, params[:id], content) + respond_to do |format| + format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} + end rescue Exception => e @message = e.message end diff --git a/app/views/pull_requests/_pull_request_comments.html.erb b/app/views/pull_requests/_pull_request_comments.html.erb index e5fa3a052..5d1c2e6ad 100644 --- a/app/views/pull_requests/_pull_request_comments.html.erb +++ b/app/views/pull_requests/_pull_request_comments.html.erb @@ -1,8 +1,3 @@ - - - - - <% @comments.each do |comment| %>
      <%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %> @@ -11,9 +6,36 @@
      <%= comment.note %>
      <% end %> -
      - - - 提 交 -
      \ No newline at end of file + <%= form_tag(url_for(:controller => 'pull_requests', :action => 'create_pull_request_comment', :project_id => @project.id), :id => 'pull_request_comment_form', :method => "post", :remote => true) do %> + + + 提交请求 + <% end %> +
      + + \ No newline at end of file diff --git a/app/views/pull_requests/pull_request_changes.js.erb b/app/views/pull_requests/pull_request_changes.js.erb index d1cf90c2f..9021c498d 100644 --- a/app/views/pull_requests/pull_request_changes.js.erb +++ b/app/views/pull_requests/pull_request_changes.js.erb @@ -1 +1 @@ -$("#merge_record_2").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>'); \ No newline at end of file +$("#merge_record_2").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes") %>'); \ No newline at end of file diff --git a/app/views/pull_requests/pull_request_commits.js.erb b/app/views/pull_requests/pull_request_commits.js.erb index 217198291..cc0a82010 100644 --- a/app/views/pull_requests/pull_request_commits.js.erb +++ b/app/views/pull_requests/pull_request_commits.js.erb @@ -1 +1 @@ -$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>'); \ No newline at end of file +$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits") %>'); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b50ee9c65..58a48ebad 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -818,6 +818,7 @@ RedmineApp::Application.routes.draw do get 'pull_request_changes' get 'update_pull_request' get 'pull_request_comments' + post 'create_pull_request_comment' end end diff --git a/public/stylesheets/css/project.css b/public/stylesheets/css/project.css index 3653cf799..6b5bdffdb 100644 --- a/public/stylesheets/css/project.css +++ b/public/stylesheets/css/project.css @@ -545,4 +545,4 @@ a:hover.upload_btn_grey{background:#8a8a8a;} .merge-discussion-detail {font-size:13px; line-height:1.5em; color:#484848; margin-top:10px;} .merge-discussion-automatic {background-color:#fdfdfd;} .merge-discussion-input {margin:0 -10px; padding:10px; background-color:#f8f8f8;} -.merge-discussion-input textarea {width:720px; height:80px; font-size:13px; line-height:16px; color:#484848; margin-bottom:10px; padding:5px;} \ No newline at end of file +.merge-discussion-input textarea {width:720px; height:80px; font-size:13px; line-height:16px; color:#484848; padding:5px;} \ No newline at end of file From dcdc09d864e30a1cd47d308f17858ac92821495f Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 9 Aug 2016 15:02:15 +0800 Subject: [PATCH 09/36] =?UTF-8?q?=E4=BF=AE=E6=94=B9gitlab=20api=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 2 +- lib/gitlab-cli/lib/gitlab/client/merge_requests.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 7dc6b7b53..a1f77dffa 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -148,7 +148,7 @@ class PullRequestsController < ApplicationController def create_pull_request_comment content = params[:pull_request_comment] begin - @comments = @g.create_merge_request_comment(@project.gpid, params[:id], content) + @comments = @g.create_merge_request_comment(@project.gpid, params[:id], content, User.current.gid) respond_to do |format| format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} end diff --git a/lib/gitlab-cli/lib/gitlab/client/merge_requests.rb b/lib/gitlab-cli/lib/gitlab/client/merge_requests.rb index 2006c58bf..b6a9ed051 100644 --- a/lib/gitlab-cli/lib/gitlab/client/merge_requests.rb +++ b/lib/gitlab-cli/lib/gitlab/client/merge_requests.rb @@ -78,8 +78,8 @@ class Gitlab::Client # @param [Integer] id The ID of a merge request. # @param [String] note The content of a comment. # @return [Gitlab::ObjectifiedHash] Information about created merge request comment. - def create_merge_request_comment(project, id, note) - post("/projects/#{project}/merge_request/#{id}/comments", :body => {:note => note}) + def create_merge_request_comment(project, id, note, gid) + post("/projects/#{project}/merge_request/#{id}/comments?user_id=#{gid}", :body => {:note => note}) end # Get a list of merge request commits. From 867434531d81a616ead01b2db7a643694cb9f150 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 9 Aug 2016 15:28:06 +0800 Subject: [PATCH 10/36] =?UTF-8?q?pull=20request=20=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 7 +++++++ app/helpers/pull_requests_helper.rb | 11 +++++++++++ app/views/pull_requests/_pull_requests_list.html.erb | 9 +++++++++ app/views/pull_requests/index.html.erb | 1 + public/stylesheets/css/project.css | 2 +- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index a1f77dffa..d65c00722 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -21,6 +21,13 @@ class PullRequestsController < ApplicationController @requests_opened_count = @requests.count @requests_merged_count = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count @requests_closed_count = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}.count + + @limit = 10 + @is_remote = true + @count = type_count(type, @requests_opened_count, @requests_merged_count, @requests_closed_count) + @pages = Paginator.new @count, @limit, params['page'] || 1 + @offset ||= @pages.offset + @requests = paginateHelper @requests, 10 respond_to do |format| format.html format.js diff --git a/app/helpers/pull_requests_helper.rb b/app/helpers/pull_requests_helper.rb index c33100ea8..fc9e7b4c8 100644 --- a/app/helpers/pull_requests_helper.rb +++ b/app/helpers/pull_requests_helper.rb @@ -25,4 +25,15 @@ module PullRequestsHelper end end + def type_count type, requests_opened_count, requests_merged_count, requests_closed_count + case type + when nil, "1" + requests_opened_count + when "2" + requests_merged_count + when "3" + requests_closed_count + end + end + end diff --git a/app/views/pull_requests/_pull_requests_list.html.erb b/app/views/pull_requests/_pull_requests_list.html.erb index e32940ca3..80866afca 100644 --- a/app/views/pull_requests/_pull_requests_list.html.erb +++ b/app/views/pull_requests/_pull_requests_list.html.erb @@ -12,4 +12,13 @@
      <% end %> + +
      +
      +
        + <%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%> +
      +
      +
      +
      <% end %> \ No newline at end of file diff --git a/app/views/pull_requests/index.html.erb b/app/views/pull_requests/index.html.erb index 23ca13178..78c4759aa 100644 --- a/app/views/pull_requests/index.html.erb +++ b/app/views/pull_requests/index.html.erb @@ -13,6 +13,7 @@ <%= render "pull_requests/pull_requests_list" %>
    + + diff --git a/config/routes.rb b/config/routes.rb index 58a48ebad..861aba437 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -626,6 +626,7 @@ RedmineApp::Application.routes.draw do match 'user_projectlist', :to => 'users#user_projectlist', :via => :get, :as => "user_projectlist" match 'sort_syllabus_list', :to => 'users#sort_syllabus_list', :via => :get, :as => "sort_syllabus_list" + match 'sort_project_list', :to => 'users#sort_project_list', :via => :get, :as => "sort_project_list" get 'edit_brief_introduction' get "user_resource"