创建pull request

This commit is contained in:
huang 2016-08-03 11:07:49 +08:00
parent 5e9c27b63d
commit 182c861b30
6 changed files with 127 additions and 105 deletions

View File

@ -33,7 +33,18 @@ class PullRequestsController < ApplicationController
description = params[:description]
source_branch = params[:source_branch]
target_branch = params[:target_branch]
g.create_merge_request(@project.gpid, :title => title, :description => description, :source_branch => source_branch, :target_branch => target_branch)
begin
request = @g.create_merge_request(@project.gpid, title, :description => description, :source_branch => source_branch, :target_branch => target_branch)
# respond_to do |format|
# format.html{redirect_to project_pull_requests_path}
# end
rescue Exception => e
@message = e.message
respond_to do |format|
format.html
end
end
@message
end
def show

View File

@ -1,22 +1,23 @@
<div class="new-merge-wrap">
<div class="merge-option-name fl mt8">标题</div><input type="text" class="merge-title-input fl ml30" />
<p class="fl ml100 fontGrey2 mt5">标题以<span class="c_red">[WIP]</span>或<span class="c_red">WIP</span>开头:以防还在进程中的合并请求在它完成之前被合并</p>
<div class="cl mb10"></div>
<div class="merge-option-name fl">描述</div><textarea type="text" 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">源分支</div><select id="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>develop</option><option>rep_quality</option></select>
<div class="cl mb10"></div>
<div class="merge-option-name fl">目标分支</div><select id="target_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>develop</option><option>dev_huang</option></select>
<div class="cl"></div>
<p class="fl ml100 mt10"><a href="javascript:void(0);" class="fr linkGrey2">修改分支</a></p>
<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">提交请求</a>
<a href="javascript:void(0);" class="fr linkGrey2 mt5 mr10">取消</a>
<div class="cl"></div>
</div>
<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create', :project_id => @project.id), :id => 'pull_request_form', :method => "post") do %>
<div class="new-merge-wrap">
<div class="merge-option-name fl mt8">标题</div><input type="text" name="title" class="merge-title-input fl ml30" />
<p class="fl ml100 fontGrey2 mt5">标题以<span class="c_red">[WIP]</span>或<span class="c_red">WIP</span>开头:以防还在进程中的合并请求在它完成之前被合并</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">源分支</div><select name="source_branch" value="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>develop</option><option>rep_quality</option></select>
<div class="cl mb10"></div>
<div class="merge-option-name fl">目标分支</div><select name="target_branch" value="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>hjq_course</option><option>hjq_beidou</option><option>develop</option><option>dev_huang</option></select>
<div class="cl"></div>
<p class="fl ml100 mt10"><a href="javascript:void(0);" class="fr linkGrey2">修改分支</a></p>
<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_form').submit()">提交请求</a>
<%= link_to "返回", project_pull_requests_path(:project_id => @project.id), :class => "fr linkGrey2 mt5 mr10" %>
<div class="cl"></div>
</div>
<% end %>

View File

@ -0,0 +1,88 @@
<% if @message %>
<div class="flash error">
<%= @message %>
</div>
<% end %>
<div id="new-merge-request" class="new-merge-request">
<div class="f14 fontGrey3 fb mb10">新的合并请求</div>
<div>
<span class="fl fontGrey2">从 <span class="fontGrey3 fb">dev_huang</span> 合并至 <span class="fontGrey3 fb">master</span></span><a href="javascript:void(0);" class="fr linkGrey2">修改分支</a>
<div class="cl"></div>
</div>
</div>
<%= render :partial => "pull_requests/form" %>
<ul class="merge-record">
<li><a href="javascript:void(0);" class="active">提交<span class="project-number-dot">1</span></a></li>
<li><a href="javascript:void(0);">改动<span class="project-number-dot">1</span></a></li>
</ul>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<div class="new-merge-wrap" id="merge_record_0">
<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">2016-08-02</span>
<p class="mt10 fontGrey2">1次提交</p>
</div>
<div class="merge-commit-detail">
<span class="fontGrey3 fb">第一次提交</span>
<p class="mt10 fontGrey2">黄井泉创建于24小时前</p>
</div>
<!--<div class="merge-commit-code">-->
<!--<span class="fontGrey3">5202e2ef</span>-->
<!--<p class="mt10"><a href="javascript:void(0);" class="link-blue">浏览文件</a></p>-->
<!--</div>-->
<div class="cl"></div>
</div>
<div id="merge_record_1" class="undis">
<div class="showing-changes-row fontGrey2" style="width:730px; margin:0 -10px;">Showing <a href="javascript:void(0)" class="linkGrey3 fb" id="changed-files">3 changed files</a> with <span class="c_green fb">3 additions</span> and <span class="c_red fb">3 deletions</span>
<ol class="mt10" id="changed-files-detail">
<li><a href="javascript:void(0)" class="linkGrey3">app/views/organizations/_org_course_homework.html.erb</a> </li>
<li><a href="javascript:void(0)" class="linkGrey3">app/views/users/_course_homework.html.erb</a> </li>
<li><a href="javascript:void(0)" class="linkGrey3">app/views/users/_user_homework_detail.html.erb</a> </li>
</ol>
</div>
<div class="showing-changes-row fontGrey2" style="width:730px; margin:0 -10px;"><a href="javascript:void(0)" class="linkGrey3"><img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" />app/views/organizations/_org_course_homework.html.erb</a></div>
<div class="showing-changes-detail" style="width:750px; margin:0 -10px;">
<table class="changes-detail-chart">
<tr>
<td class="diff-line-number fontGrey2">99</td>
<td class="diff-line-number fontGrey2">99</td>
<td class="fontGrey2 p10">&lt;% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %&gt;</td>
</tr>
<tr>
<td class="diff-line-number fontGrey2">100</td>
<td class="diff-line-number fontGrey2">100</td>
<td class="fontGrey2 p10">&lt;div class="mt10"&gt;</td>
</tr>
<tr>
<td class="diff-line-number fontGrey2 number-line-old">111</td>
<td class="diff-line-number fontGrey2 number-line-old"></td>
<td class="fontGrey2 p10 code-line-old">- &lt;div class="fl mr5 fontGrey3"&gt;</td>
</tr>
<tr class="code-line-new">
<td class="diff-line-number fontGrey2 number-line-new"></td>
<td class="diff-line-number fontGrey2 number-line-new">111</td>
<td class="fontGrey2 p10 code-line-new">+ &lt;div class="fl mr20 fontGrey3 w80"&gt;</td>
</tr>
</table>
</div>
</div>
<script>
$("#new-merge-request").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 @@
<%= render :partial => "pull_requests/new" %>

View File

@ -4,7 +4,7 @@
<li><a href="javascript:void(0);">合并<span class="project-number-dot">1</span></a></li>
<li><a href="javascript:void(0);">关闭<span class="project-number-dot">1</span></a></li>
<li class="active"><a href="javascript:void(0);">全部<span class="project-number-dot">3</span></a></li>
<a href="javascript:void(0);" class="BlueCirBtn fr ml10 mt10">新建请求</a>
<%= 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>

View File

@ -1,82 +1,2 @@
<div id="new-merge-request" class="new-merge-request">
<div class="f14 fontGrey3 fb mb10">新的合并请求</div>
<div>
<span class="fl fontGrey2">从 <span class="fontGrey3 fb">dev_huang</span> 合并至 <span class="fontGrey3 fb">master</span></span><a href="javascript:void(0);" class="fr linkGrey2">修改分支</a>
<div class="cl"></div>
</div>
</div>
<%= render :partial => "pull_requests/form" %>
<ul class="merge-record">
<li><a href="javascript:void(0);" class="active">提交<span class="project-number-dot">1</span></a></li>
<li><a href="javascript:void(0);">改动<span class="project-number-dot">1</span></a></li>
</ul>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<div class="new-merge-wrap" id="merge_record_0">
<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">2016-08-02</span>
<p class="mt10 fontGrey2">1次提交</p>
</div>
<div class="merge-commit-detail">
<span class="fontGrey3 fb">第一次提交</span>
<p class="mt10 fontGrey2">黄井泉创建于24小时前</p>
</div>
<div class="merge-commit-code">
<span class="fontGrey3">5202e2ef</span>
<p class="mt10"><a href="javascript:void(0);" class="link-blue">浏览文件</a></p>
</div>
<div class="cl"></div>
</div>
<div id="merge_record_1" class="undis">
<div class="showing-changes-row fontGrey2" style="width:730px; margin:0 -10px;">Showing <a href="javascript:void(0)" class="linkGrey3 fb" id="changed-files">3 changed files</a> with <span class="c_green fb">3 additions</span> and <span class="c_red fb">3 deletions</span>
<ol class="mt10" id="changed-files-detail">
<li><a href="javascript:void(0)" class="linkGrey3">app/views/organizations/_org_course_homework.html.erb</a> </li>
<li><a href="javascript:void(0)" class="linkGrey3">app/views/users/_course_homework.html.erb</a> </li>
<li><a href="javascript:void(0)" class="linkGrey3">app/views/users/_user_homework_detail.html.erb</a> </li>
</ol>
</div>
<div class="showing-changes-row fontGrey2" style="width:730px; margin:0 -10px;"><a href="javascript:void(0)" class="linkGrey3"><img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" />app/views/organizations/_org_course_homework.html.erb</a></div>
<div class="showing-changes-detail" style="width:750px; margin:0 -10px;">
<table class="changes-detail-chart">
<tr>
<td class="diff-line-number fontGrey2">99</td>
<td class="diff-line-number fontGrey2">99</td>
<td class="fontGrey2 p10">&lt;% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %&gt;</td>
</tr>
<tr>
<td class="diff-line-number fontGrey2">100</td>
<td class="diff-line-number fontGrey2">100</td>
<td class="fontGrey2 p10">&lt;div class="mt10"&gt;</td>
</tr>
<tr>
<td class="diff-line-number fontGrey2 number-line-old">111</td>
<td class="diff-line-number fontGrey2 number-line-old"></td>
<td class="fontGrey2 p10 code-line-old">- &lt;div class="fl mr5 fontGrey3"&gt;</td>
</tr>
<tr class="code-line-new">
<td class="diff-line-number fontGrey2 number-line-new"></td>
<td class="diff-line-number fontGrey2 number-line-new">111</td>
<td class="fontGrey2 p10 code-line-new">+ &lt;div class="fl mr20 fontGrey3 w80"&gt;</td>
</tr>
</table>
</div>
</div>
<%= render :partial => "pull_requests/new" %>
<script>
$("#new-merge-request").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>