每次请求提交的代码

This commit is contained in:
huang 2016-08-03 14:43:27 +08:00
parent be081f5c66
commit 0a9224d036
6 changed files with 57 additions and 50 deletions

View File

@ -1,6 +1,6 @@
class PullRequestsController < ApplicationController
before_filter :find_project_and_repository
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pll_request, :pull_request_commits, :pull_request_changes]
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes]
layout "base_projects"
# 返回json格式
@ -49,6 +49,7 @@ class PullRequestsController < ApplicationController
def show
@request = @g.merge_request(@project.gpid, params[:id])
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
end
# Accept a merge request.
@ -63,7 +64,7 @@ class PullRequestsController < ApplicationController
# @return [Gitlab::ObjectifiedHash]
def accept_pull_request
commit_id = parmas[:commit_id]
status = @g.accept_pull_rquest(@project.gpid, commit_id)
status = @g.accept_merge_rquest(@project.gpid, commit_id)
if status == '200'
# 需跳入的地方
end
@ -71,12 +72,12 @@ class PullRequestsController < ApplicationController
# 获取某次请求的提交次数
def pull_request_commits
@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])
end
private

View File

@ -0,0 +1,32 @@
<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>

View File

@ -0,0 +1,16 @@
<% @commits.each do |commit| %>
<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>-->
</div>
<div class="merge-commit-detail">
<span class="fontGrey3 fb"><%= commit.title %></span>
<p class="mt10 fontGrey2"><%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %>创建于24小时前</p>
</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>
<% end %>

View File

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

View File

@ -17,53 +17,10 @@
</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>
<%= render :partial => "pull_requests/pull_request_commits" %>
</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>
<%= render :partial => "pull_requests/pull_request_changes" %>
</div>
<script>

View File

@ -118,7 +118,7 @@ class Gitlab::Client
# @param [Integer] project The ID of a project.
# @param [Integer] id The ID of a merge request.
# @return [Gitlab::ObjectifiedHash]
def accept_pull_rquest(project, id)
def accept_merge_rquest(project, id)
put("/projects/#{project}/merge_request/#{id}/merge")
end