Merge branch 'rep_quality' into develop

This commit is contained in:
huang 2016-08-05 15:28:39 +08:00
commit 81ce93e88b
34 changed files with 559 additions and 15 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the pull_requests controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,135 @@
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]
layout "base_projects"
include PullRequestsHelper
include ApplicationHelper
# 返回json格式
def index
type = params[:type]
case type
when nil, "1"
@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"}
end
@requests_opened_count = @requests.count
@requests_merged_count = params[:type] ? @requests.count : @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count
respond_to do |format|
format.html
format.js
end
end
# 主要取源项目和目标项目分支及标识(用户名/版本库名)
def new
identifier = get_rep_identifier_by_project @project
@source_project_name = "#{get_user_name(@project.user_id)}/#{identifier}"
@source_rev = @g.branches(@project.gpid).map{|b| b.name}
# 获取forked源项目信息
if @project.forked_from_project_id
@forked_project = Project.find(@project.forked_from_project_id)
identifier = get_rep_identifier_by_project @forked_project
@forked_project_name = "#{get_user_name(@forked_project.user_id)}/#{identifier}"
@forked_rev = @g.branches(@forked_project.gpid).map{|b| b.name}
end
end
# Creates a merge request.
# If the operation is successful, 200 and the newly created merge request is returned. If an error occurs, an error number and a message explaining the reason is returned.
#
# @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)
#
# @param [Integer] project The ID of a project.
# @param [String] title The title of a merge request.
# @param [Hash] options A customizable set of options.
# @option options [String] :source_branch (required) The source branch name.
# @option options [String] :target_branch (required) The target branch name.
# @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
# @return [Gitlab::ObjectifiedHash] Information about created merge request.
def create
title = params[:title]
description = params[:description]
source_branch = params[:source_branch]
target_branch = params[:target_branch]
begin
# 如果传送了目标项目ID则PR请求发至目标项目
if params[:forked_project_id] && params[:source_project] == "forked_project_name"
target_project_id = params[:forked_project_id].to_i
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(@project.forked_from_project_id).try(:name)
@fork_pr_message = true if @fork_project_name
else
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
respond_to do |format|
format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)}
end
end
rescue Exception => e
@message = e.message
end
end
def show
@type = params[:type]
@request = @g.merge_request(@project.gpid, params[:id])
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
@commits_count = @commits.count
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count
end
# Accept a merge request.
# If merge success you get 200 OK.
# Accept a merge request.
#
# @example
# Gitlab.accept_pull_rquest(5, 1)
#
# @param [Integer] project The ID of a project.
# @param [Integer] id The ID of a merge request.
# @return [Gitlab::ObjectifiedHash]
def accept_pull_request
begin
status = @g.accept_merge_rquest(@project.gpid, params[:id])
respond_to do |format|
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
end
rescue Exception => e
@message = e.message
end
end
# 获取某次请求的提交次数
def pull_request_commits
@type = parms[:type]
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
end
# 获取某次请求的改动
def pull_request_changes
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count
end
private
def connect_gitlab
@g = Gitlab.client
end
def find_project_and_repository
@project = Project.find(params[:project_id])
render_404 if @project.gpid.blank?
@repository = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab")
rescue ActiveRecord::RecordNotFound
render_404
end
end

View File

@ -43,6 +43,12 @@ module ApplicationHelper
user.nil? ? User.find(2) : user user.nil? ? User.find(2) : user
end end
# 通过系统外部用户名查找用户,如果用户不存在则用邮箱替换
def get_user_by_login_and login
user = User.find_by_login(login)
user.nil? ? User.find(2) : user
end
# 历史数据(老版本库数据)处理完则可以修改该放放 # 历史数据(老版本库数据)处理完则可以修改该放放
def get_rep_identifier_by_project project def get_rep_identifier_by_project project
identifier = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier) identifier = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier)
@ -814,6 +820,18 @@ module ApplicationHelper
return @result return @result
end end
# 必须是项目成,项目必须提交过代码
def allow_pull_request project
return false if project.gpid.nil?
g = Gitlab.client
count = g.user_static(project.gpid, :rev => "master").count
if User.current.member_of?(project) && count > 0
true
else
false
end
end
# 判断版本库是否初始为gitlab # 判断版本库是否初始为gitlab
def rep_is_gitlab?(project) def rep_is_gitlab?(project)
rep = project.repositories.where("type =?", "Repository::Gitlab") rep = project.repositories.where("type =?", "Repository::Gitlab")

View File

@ -0,0 +1,17 @@
module PullRequestsHelper
# 获取diff内容行号
def diff_line_num content
content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.nil? ? "" : content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i
end
# 处理内容
def diff_content content
content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'')
end
def get_user_name user_id
User.find(user_id).try(:login)
end
end

View File

@ -1236,8 +1236,7 @@ class Project < ActiveRecord::Base
# 创建项目后在项目下同步创建一个讨论区 # 创建项目后在项目下同步创建一个讨论区
def create_board_sync def create_board_sync
@board = self.boards.build @board = self.boards.build
self.name=" #{l(:label_borad_project) }" @board.name = " #{l(:label_borad_project) }"
@board.name = self.name
@board.description = self.name.to_s @board.description = self.name.to_s
if @board.save if @board.save
logger.debug "[Project Model] ===> #{@board.to_json}" logger.debug "[Project Model] ===> #{@board.to_json}"

View File

@ -39,6 +39,14 @@
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<% if allow_pull_request(@project) %>
<div class="subNav">
<%= link_to "Pull Requests", project_pull_requests_path(@project), :class => "f14 c_blue02" %>
<%= link_to "+新建请求", new_project_pull_request_path(:project_id => @project.id), :class => "subnav_green" %>
</div>
<% end %>
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %> <%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
<% if visible_repository?(@project) %> <% if visible_repository?(@project) %>
<div class="subNav"> <div class="subNav">
@ -57,6 +65,8 @@
</div> </div>
<% end %> <% end %>
<!-- more --> <!-- more -->
<div class="subNav subNav_jiantou" id="expand_tools_expand"><%= l(:label_project_more) %></div> <div class="subNav subNav_jiantou" id="expand_tools_expand"><%= l(:label_project_more) %></div>
<ul class="navContent" id="navContent"> <ul class="navContent" id="navContent">
<%= render 'projects/tools_expand' %> <%= render 'projects/tools_expand' %>

View File

@ -0,0 +1,7 @@
<% if @message %>
<div class="flash error"><%= @message %></div>
<% end %>
<% if @fork_pr_message %>
<div class="flash notice">您的Pull Request请求已成功发送至源项目<%= @fork_project_name %></div>
<% end %>

View File

@ -0,0 +1,67 @@
<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create', :project_id => @project.id, :forked_project_id => @forked_project.try(:gpid)), :id => 'pull_request_form', :method => "post", :remote => true) do %>
<div class="new-merge-wrap">
<div class="merge-option-name fl mt8"><span class="c_red">*</span>标题</div><input type="text" id="pr_name" name="title" class="merge-title-input fl ml30" />
<p id ="pull_request_title" class="fl ml100 fontGrey2 mt5 c_red" style="display: none">标题不能为空</p>
<div class="cl mb10"></div>
<div class="merge-option-name fl">描述</div><textarea type="text" name="description" class="merge-description-input fl ml30"></textarea>
<!--<p class="fl ml100 f12 mt5"><a href="javascript:void(0);" class="AnnexBtn fl mr10">上传附件</a></p>-->
<div class="cl"></div>
</div>
<div class="new-merge-wrap borderBottomNone">
<div class="merge-option-name fl" style="padding:5px 0">源分支</div>
<%= select_tag :branch, options_for_select(@source_rev), :name => "source_branch", :value => "source_branch", :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;" %>
<div class="cl mb10"></div>
<div class="merge-option-name fl" style="padding:5px 0">目标分支</div>
<% if @forked_project.nil? %>
<%= select_tag :branch, options_for_select(@source_rev), :name => "target_branch", :value => "target_branch",:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetBranch" %>
<% else %>
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" name="source_project" value="source_project" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;">
<option value="source_project_name"><%= @source_project_name %></option>
<option value="forked_project_name"><%= @forked_project_name %></option>
</select>
<select name="target_branch" id="pull_request_branch" class = "ml30 fontGrey3 fb fl" style = "width:140px; padding:5px 0 5px 5px;">
<% @source_rev.each do |rev| %>
<option value="<%= rev %>"><%= rev %></option>
<% end %>
</select>
<% end %>
<div class="cl"></div>
</div>
<div class="new-merge-row b_grey" style="border-top:1px solid #ddd;">
<a href="javascript:void(0);" class="BlueCirBtn fl ml10" onclick="pull_request_commit()">提交请求</a>
<%= link_to "返回", project_pull_requests_path(:project_id => @project.id), :class => "fr linkGrey2 mt5 mr10" %>
<div class="cl"></div>
</div>
<% end %>
<script>
function regex_pr_name()
{
var name = $.trim($("#pr_name").val());
if(name.length == 0)
{
$("#pull_request_title").show();
return false;
}
else
{
$("#pull_request_title").hide();
return true;
}
}
//提交pull request
function pull_request_commit()
{
if(regex_pr_name())
{
$("#pull_request_form").submit();
}
}
//切换项目时,替换分支
$("#targetProject").change(function(){
var defaultBranch = $("#targetBranch option:first-child").val();
$("#targetBranch").val(defaultBranch);
});
</script>

View File

@ -0,0 +1,30 @@
<div id="pull_request_new_form">
<div id="create_pull_request_error">
<%= render :partial => "pull_requests/error_message" %>
</div>
<div class="new-merge-request">
<div class="f14 fontGrey3 fb mb10">新的合并请求</div>
</div>
<%= render :partial => "pull_requests/form" %>
</div>
<script>
$("#pull_request_new_form").parent().css("width","730px");
$("#changed-files").toggle(function(){
$("#changed-files-detail").show();
},function(){
$("#changed-files-detail").hide();
});
$(".merge-record li a").click(function(){
$(".merge-record li a").removeClass("active");
$(this).addClass("active");
var index = $(".merge-record li a").index(this);
$("#merge_record_0, #merge_record_1").hide();
$("#merge_record_" + index).show();
});
</script>

View File

@ -0,0 +1,33 @@
<% unless @changes.blank? %>
<% @changes.each do |cd| %>
<div class="showing-changes-row fontGrey2" style="width:710px;">
<a class="linkGrey3" id="changed-files">
<img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" /><%= cd['new_path'] %>
</a>
</div>
<div class="autoscroll">
<table class="filecontent syntaxhl" style="width:100%;" >
<tbody>
<% line_num = diff_line_num(cd['diff']) %>
<% diff_content = diff_content(cd['diff']) %>
<% syntax_highlight_lines('new_path', Redmine::CodesetUtil.to_utf8_by_setting(diff_content)).each do |line| %>
<tr>
<th class="line-num" id="L<%= line_num %>" style="vertical-align: top;">
<a href="#L<%= line_num %>" style="padding-top: 0px;"><%= line_num %></a>
</th>
<% if line[0,1] == "-" %>
<td class="line-code diff_out"><pre style="white-space:pre;"><%= line.html_safe %></pre></td>
<% elsif line[0,1] == "+" %>
<td class="line-code diff_in"><pre style="white-space:pre;"><%= line.html_safe %></pre></td>
<% else%>
<td class="line-code"><pre style="white-space:pre;"><%= line.html_safe %></pre></td>
<% end %>
</tr>
<% line_num += 1 %>
<% end %>
</tbody>
</table>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,19 @@
<% @commits.each do |commit| %>
<div class="new-merge-wrap">
<div class="merge-commit-time">
<img width="16" class="ui-datepicker-trigger mr15" style="cursor:default; margin-top:3px; margin-left:0;" /><span class="fontGrey3"><%= format_date(commit.created_at) %></span>
<!--<p class="mt10 fontGrey2">1次提交</p>-->
<p class="mt10 fontGrey2"><%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %>创建于<%= time_tag(commit.created_at) %>前</p>
</div>
<div class="merge-commit-detail">
<span class="fontGrey3 fb"><%= commit.title %></span>
</div>
<div class="merge-commit-code">
<span class="fontGrey3">
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %>
</span>
</div>
<div class="cl"></div>
</div>
<% end %>

View File

@ -0,0 +1,3 @@
<script>
$("#RSide").before("<div class='homepageRightBanner mb10'><span class='f16 fontGrey3'>Pull Request</span></div>");
</script>

View File

@ -0,0 +1,15 @@
<% if @requests.blank? %>
<div class="no-merge-content">没有可显示的请求</div>
<% else %>
<% @requests.each do |request| %>
<li>
<% request %>
<%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%>
<!--<a href="javascript:void(0);" class="fr fontGrey2 fb"><img src="/images/comments.png" class="mr5" width="15" />0</a><span class="fr mr15 fb fontGrey2">关闭</span>-->
<div class="cl mb5"></div>
<span class="fontGrey2">由 <%= 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) %></span>
<span class="fr fontGrey2"><%= time_tag(request.updated_at) %>更新</span>
<div class="cl"></div>
</li>
<% end %>
<% end %>

View File

@ -0,0 +1,60 @@
<div id="create_pull_request_error">
<%= render :partial => "pull_requests/error_message" %>
</div>
<div id="pull_request_show">
<div id="mergeShow" class="f14 fontGrey2 merge-show">
<span class="mr10 open-status"><%= @request.state == "merged" ? "已合并" : "待处理" %></span><span class="mr10">合并请求</span> 由<%= 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) %>
<!--<a href="javascript:void(0);" class="BlueCirBtnMini fr mt5">编辑</a>-->
<div class="cl"></div>
</div>
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>
<div class="mt10 mb15">
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
<div class="merge-commit-option mt15">
<% if @commits_count == 0 && @changes_count == 0 %>
<span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br />
<p class="fontGrey2 mt5">请将新改动提交至源分支或者切换到其它目标分支</p>
<% else %>
<% if @request.state == "merged" %>
<span class="fontGrey3 fb" style="font-size:13px;"><a href="javascript:void(0);" class="link-blue"> Hjqreturn</a>于两小时前合并</span><br />
<p class="fontGrey2 mt5">改动已合并至<%= @request.target_branch %></p>
<% else %>
<%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :class => "BlueCirBtn", :remote => true %>
<% end %>
</div>
</div>
<ul class="merge-record" style="border-top:1px solid #ddd;">
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
</ul>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<div id="merge_record_0">
<%= render :partial => "pull_requests/pull_request_commits" %>
</div>
<div id="merge_record_1" class="undis">
<%= render :partial => "pull_requests/pull_request_changes" %>
</div>
<% end %>
</div>
<script>
$("#pull_request_show").parent().css("width","730px");
$("#changed-files").toggle(function(){
$("#changed-files-detail").show();
},function(){
$("#changed-files-detail").hide();
});
$(".merge-record li a").click(function(){
$(".merge-record li a").removeClass("active");
$(this).addClass("active");
var index = $(".merge-record li a").index(this);
$("#merge_record_0, #merge_record_1").hide();
$("#merge_record_" + index).show();
});
</script>

View File

@ -0,0 +1,2 @@
$("#create_pull_request_error").html('<%= escape_javascript(render :partial => "pull_requests/error_message") %>');

View File

@ -0,0 +1,3 @@
<%= render :partial => "pull_requests/pull_request_container" %>
<%= render :partial => "pull_requests/new" %>

View File

@ -0,0 +1 @@
$("#create_pull_request_error").html('<%= escape_javascript(render :partial => "pull_requests/error_message") %>');

View File

@ -0,0 +1,22 @@
<%= render :partial => "pull_requests/pull_request_container" %>
<ul id="mergeBanner" class="project-merge-banner">
<li class="active"><%= link_to "待处理<span class='project-number-dot'>#{@requests_opened_count}</span>".html_safe, project_pull_requests_path(:type => "1"), :remote => true %></li>
<li><%= link_to "已处理<span class='project-number-dot'>#{@requests_merged_count}</span>".html_safe, project_pull_requests_path(:type => "2"), :remote => true %></li>
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
<div class="cl"></div>
</ul>
<div class="cl"></div>
<ul class="project-merge-content" id="pull_requests_list">
<%= render "pull_requests/pull_requests_list" %>
</ul>
<script>
$("#mergeBanner").parent().css("width","730px");
$(".project-merge-banner li").click(function(){
$(".project-merge-banner li").removeClass("active");
$(this).addClass("active");
});
</script>

View File

@ -0,0 +1 @@
$("#pull_requests_list").html('<%= escape_javascript( render :partial => "pull_requests/pull_requests_list", :locals => {:type => @type} ) %>');

View File

@ -0,0 +1,3 @@
<%= render :partial => "pull_requests/pull_request_container" %>
<%= render :partial => "pull_requests/new" %>

View File

@ -0,0 +1 @@
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>');

View File

@ -0,0 +1 @@
$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>');

View File

@ -0,0 +1,2 @@
<%= render :partial => "pull_requests/pull_request_container" %>
<%= render :partial => "pull_requests/show" %>

View File

@ -0,0 +1,3 @@
<%# 详情页面和新建页面都会跳入,所以用两种局部刷新 %>
$("#pull_request_new_form").html('<%= escape_javascript(render :partial => "pull_requests/show") %>');
$("#pull_request_show").html('<%= escape_javascript(render :partial => "pull_requests/show") %>');

View File

@ -805,6 +805,16 @@ RedmineApp::Application.routes.draw do
end end
end end
resources :pull_requests do
collection do
end
member do
get 'accept_pull_request'
get 'pull_request_commits'
get 'pull_request_changes'
end
end
resources :quality_analysis, :only => [:index, :create, :edit, :update, :delete] do resources :quality_analysis, :only => [:index, :create, :edit, :update, :delete] do
collection do collection do
end end

View File

@ -43,11 +43,11 @@ class Gitlab::Client
# @option options [String] :target_branch (required) The target branch name. # @option options [String] :target_branch (required) The target branch name.
# @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request. # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
# @return [Gitlab::ObjectifiedHash] Information about created merge request. # @return [Gitlab::ObjectifiedHash] Information about created merge request.
def create_merge_request(project, title, options={}) def create_merge_request(project, title, gid, options={})
check_attributes!(options, [:source_branch, :target_branch]) check_attributes!(options, [:source_branch, :target_branch])
body = {:title => title}.merge(options) body = {:title => title}.merge(options)
post("/projects/#{project}/merge_requests", :body => body) post("/projects/#{project}/merge_requests?user_id=#{gid}", :body => body)
end end
# Updates a merge request. # Updates a merge request.
@ -82,6 +82,22 @@ class Gitlab::Client
post("/projects/#{project}/merge_request/#{id}/comments", :body => {:note => note}) post("/projects/#{project}/merge_request/#{id}/comments", :body => {:note => note})
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 merge_request_commits(project, id)
get("/projects/#{project}/merge_request/#{id}/commits")
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 merge_request_changes(project, id)
get("/projects/#{project}/merge_request/#{id}/changes")
end
# Gets the comments on a merge request. # Gets the comments on a merge request.
# #
# @example # @example
@ -94,6 +110,18 @@ class Gitlab::Client
get("/projects/#{project}/merge_request/#{id}/comments") get("/projects/#{project}/merge_request/#{id}/comments")
end end
# Accept a merge request.
#
# @example
# Gitlab.accept_pull_rquest(5, 1)
#
# @param [Integer] project The ID of a project.
# @param [Integer] id The ID of a merge request.
# @return [Gitlab::ObjectifiedHash]
def accept_merge_rquest(project, id)
put("/projects/#{project}/merge_request/#{id}/merge")
end
private private
def check_attributes!(options, attrs) def check_attributes!(options, attrs)

View File

@ -658,3 +658,23 @@ function search_tag_attachment(url,tag_name,q,course_id,sort)
} }
} }
function choice_branch(name, branch, source_rev, forked_rev) {
switch (name) {
case "source_project_name" :
var branchOptions = source_rev;
break;
case "forked_project_name" :
var branchOptions = forked_rev;
break;
default:
var branchOptions = source_rev;
break;
}
branch.options.length = 0;
for (var i = 0; i < branchOptions.length; i++) {
branch.options[i] = new Option(branchOptions[i]);
}
}

View File

@ -94,9 +94,6 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.flow_hidden{ width:300px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} .flow_hidden{ width:300px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;}
.white_space{white-space:nowrap;} .white_space{white-space:nowrap;}
.pr {position:relative;} .pr {position:relative;}
.fontGrey3 {color:#484848;}
a.linkGrey6 {color:#484848 !important;}
a.linkGrey6:hover {color:#ffffff !important;}
.markPopup {width:290px; height:auto; padding:5px 0px 15px 15px; background-color:#ffffff; z-index:1000;} .markPopup {width:290px; height:auto; padding:5px 0px 15px 15px; background-color:#ffffff; z-index:1000;}
.markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:50px; color:#3d3c3c; margin-bottom:10px; text-align:center; margin-right:5px; padding-left:0;} .markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:50px; color:#3d3c3c; margin-bottom:10px; text-align:center; margin-right:5px; padding-left:0;}
.markPercentage {margin:10px 0; border:1px solid #e6e6e6; width:70px; height:30px; outline:none; font-size:12px; color:#3d3c3c;} .markPercentage {margin:10px 0; border:1px solid #e6e6e6; width:70px; height:30px; outline:none; font-size:12px; color:#3d3c3c;}
@ -545,6 +542,10 @@ a:hover.BlueCirBtnMini{ background:#269ac9; color:#fff;}
.borderRadius {border-radius:5px;} .borderRadius {border-radius:5px;}
a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.Blue-btn{ background:#3598db; color:#fff;} a:hover.Blue-btn{ background:#3598db; color:#fff;}
a.BlueCirBtn{ display:block;width:75px; height:28px; background-color:#fff; line-height:28px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.BlueCirBtn{ background:#3598db; color:#fff;}
a.BlueCirBtnMini{ display:block;width:40px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.BlueCirBtnMini{ background:#3598db; color:#fff;}
/*20160725 项目申请按钮*/ /*20160725 项目申请按钮*/
a.sy_btn_grey{ a.sy_btn_grey{

View File

@ -8,14 +8,10 @@
.HomeWork {width:718px; background-color:#ffffff; padding:15px; border:1px solid #dddddd; float:right;} .HomeWork {width:718px; background-color:#ffffff; padding:15px; border:1px solid #dddddd; float:right;}
.RightBanner {font-size:16px; width:733px; color:#4b4b4b; padding:10px 0 0 15px; margin-bottom:10px; background:#fff; border:1px solid #dddddd;height:34px;} .RightBanner {font-size:16px; width:733px; color:#4b4b4b; padding:10px 0 0 15px; margin-bottom:10px; background:#fff; border:1px solid #dddddd;height:34px;}
select.InputBox,input.InputBox,textarea.InputBox{ border:1px solid #d9d9d9; color:#888888; height:28px; line-height:28px; padding-left:5px; font-size:14px;} select.InputBox,input.InputBox,textarea.InputBox{ border:1px solid #d9d9d9; color:#888888; height:28px; line-height:28px; padding-left:5px; font-size:14px;}
a.BlueCirBtn{ display:block;width:75px; height:28px; background-color:#fff; line-height:28px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.BlueCirBtn{ background:#3598db; color:#fff;}
/*a.AnnexBtn{ background: url(../images/homepage_icon.png) 0px -343px no-repeat; width:70px; height:20px; display:block; padding-left:20px; color:#888888;}*/ /*a.AnnexBtn{ background: url(../images/homepage_icon.png) 0px -343px no-repeat; width:70px; height:20px; display:block; padding-left:20px; color:#888888;}*/
/*a:hover.AnnexBtn{background: url(../images/homepage_icon.png) -90px -343px no-repeat; color:#3598db;}*/ /*a:hover.AnnexBtn{background: url(../images/homepage_icon.png) -90px -343px no-repeat; color:#3598db;}*/
a.FilesBtn{ background: url(../images/homepage_icon.png) 0px -373px no-repeat; width:38px; height:20px; display:block; padding-left:20px; color:#888888;} a.FilesBtn{ background: url(../images/homepage_icon.png) 0px -373px no-repeat; width:38px; height:20px; display:block; padding-left:20px; color:#888888;}
a:hover.FilesBtn{background: url(../images/homepage_icon.png) -89px -372px no-repeat; color:#3598db;} a:hover.FilesBtn{background: url(../images/homepage_icon.png) -89px -372px no-repeat; color:#3598db;}
a.BlueCirBtnMini{ display:block;width:40px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.BlueCirBtnMini{ background:#3598db; color:#fff;}
a.ProBtn{background: url(../images/homepage_icon.png) -86px -396px no-repeat; width:30px; height:20px; display:block; padding-left:20px; color:#888888;} a.ProBtn{background: url(../images/homepage_icon.png) -86px -396px no-repeat; width:30px; height:20px; display:block; padding-left:20px; color:#888888;}
a:hover.ProBtn{background: url(../images/homepage_icon.png) -86px -426px no-repeat; color:#3598db;} a:hover.ProBtn{background: url(../images/homepage_icon.png) -86px -426px no-repeat; color:#3598db;}

View File

@ -514,3 +514,30 @@ a:hover.upload_btn_grey{background:#8a8a8a;}
.analysis-result-debt {width:160px; text-align:right;} .analysis-result-debt {width:160px; text-align:right;}
.analysis-result-time {width:150px; text-align:right;} .analysis-result-time {width:150px; text-align:right;}
.analysis-name-icon {background:url(/images/code-analysis-icon.png) -2px -148px no-repeat; width:16px; height:16px; display:inline-block; vertical-align:middle;} .analysis-name-icon {background:url(/images/code-analysis-icon.png) -2px -148px no-repeat; width:16px; height:16px; display:inline-block; vertical-align:middle;}
/*20160801项目合并*/
.project-merge-banner {margin:-10px -10px 0 -10px; padding:0 10px; border-bottom:1px solid #ddd;}
.project-merge-banner li {float:left;}
.project-merge-banner .active {border-bottom:2px solid #3b94d6;}
.project-merge-banner li a {padding:14px; font-size:14px; color:#555; display:inline-block;}
.project-number-dot {display:inline-block; min-width:10px; padding:3px 5px; font-size:12px; color:#888; line-height:1; vertical-align:middle; white-space:nowrap; text-align:center; background-color:#eee; border-radius:10px; margin-left:5px;}
.project-merge-content {}
.project-merge-content li {padding:10px; margin:0 -10px; background-color:#f9f9f9; border-bottom:1px solid #e5e5e5;}
.no-merge-content {padding:10px 15px; color:#888;}
.new-merge-request {border-bottom:1px solid #ddd; padding-bottom:10px;}
.new-merge-wrap {font-size:13px; color:#484848; border-bottom:1px solid #ddd; padding:10px 0;}
.new-merge-row {font-size:13px; color:#484848; border-bottom:1px solid #ddd; margin:0 -10px; padding:10px;}
.merge-option-name {width:70px; text-align:right; }
.merge-title-input {width:610px; height:16px; padding:8px 5px; border-radius:2px;}
.merge-description-input {width:610px; height:90px; line-height:18px; padding:8px 5px;}
.merge-record {font-size:13px; color:#484848; border-bottom:1px solid #ddd; margin:0 -10px; text-align:center;}
.merge-record li {display:inline-block;}
.merge-record li a {display:inline-block; padding:10px;}
.merge-record .active {border-bottom:2px solid #3b94d6;}
.merge-commit-time {width:200px; float:left;}
.merge-commit-detail {width:380px; float:left;}
.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;}

View File

@ -148,7 +148,6 @@ a.opnionButton:hover{background: #297fb8; }
.hiddent{ overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} .hiddent{ overflow:hidden; white-space: nowrap; text-overflow:ellipsis;}
.break_word_firefox{white-space: pre-wrap;word-break: break-all;}
.font_bold{font-weight: bold;} .font_bold{font-weight: bold;}
@ -443,7 +442,7 @@ a.sortArrowActiveU {background:url(../images/post_image_list.png) -17px -20px no
.postDetailWrap {width:655px; float:left;} .postDetailWrap {width:655px; float:left;}
.postDetailTitle {width:570px; max-width:570px; margin-bottom:5px;} .postDetailTitle {width:570px; max-width:570px; margin-bottom:5px;}
.postDetailDes {width:580px; max-width:580px; margin-bottom:6px; color:#888888;display:block;overflow:hidden;word-break:keep-all;text-overflow:ellipsis;} .postDetailDes {width:580px; max-width:580px; margin-bottom:6px; color:#888888;display:block;overflow:hidden;word-break:keep-all;text-overflow:ellipsis;}
.postDetailDes p,div,em{word-break: break-all;word-wrap: break-word;} /*.postDetailDes p,div,em{word-break: break-all;word-wrap: break-word;}*/
.postDetailDes ol li{list-style-type: decimal;margin-left: 40px;} .postDetailDes ol li{list-style-type: decimal;margin-left: 40px;}
.postDetailDes ul li{list-style-type: disc;margin-left: 40px;} .postDetailDes ul li{list-style-type: disc;margin-left: 40px;}
.postDetailDes td,.postDetailDes tr {border: 1px solid; border-color: inherit;} .postDetailDes td,.postDetailDes tr {border: 1px solid; border-color: inherit;}

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe PullRequestsController, :type => :controller do
end