diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index a0be304a3..8d49207ee 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -1,6 +1,6 @@ class PullRequestsController < ApplicationController before_filter :find_project_and_repository - before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pr] + before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pll_request, :pull_request_commits, :pull_request_changes] layout "base_projects" # 返回json格式 @@ -9,7 +9,6 @@ class PullRequestsController < ApplicationController end def new - end # Creates a merge request. @@ -35,9 +34,10 @@ class PullRequestsController < ApplicationController target_branch = params[: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 + e.message + respond_to do |format| + format.html{redirect_to project_pull_requests_path(request.id, :source_branch => source_branch, :target_branch => target_branch)} + end rescue Exception => e @message = e.message respond_to do |format| @@ -48,7 +48,7 @@ class PullRequestsController < ApplicationController end def show - #@request = @g.merge_request(@rpoject.gpid, id) + @request = @g.merge_request(@project.gpid, params[:id]) end # Accept a merge request. @@ -61,7 +61,7 @@ class PullRequestsController < ApplicationController # @param [Integer] project The ID of a project. # @param [Integer] id The ID of a merge request. # @return [Gitlab::ObjectifiedHash] - def accept_pr + def accept_pull_request commit_id = parmas[:commit_id] status = @g.accept_pull_rquest(@project.gpid, commit_id) if status == '200' @@ -69,6 +69,16 @@ class PullRequestsController < ApplicationController end end + # 获取某次请求的提交次数 + def pull_request_commits + + end + + # 获取某次请求的改动 + def pull_request_changes + + end + private def connect_gitlab @g = Gitlab.client diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9d0439120..69da2657b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -43,6 +43,12 @@ module ApplicationHelper user.nil? ? User.find(2) : user 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 identifier = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier) diff --git a/app/views/pull_requests/create.html.erb b/app/views/pull_requests/create.html.erb index f51a0e654..034f30163 100644 --- a/app/views/pull_requests/create.html.erb +++ b/app/views/pull_requests/create.html.erb @@ -1,2 +1,3 @@ +<%= render :partial => "pull_requests/pull_request_container" %> <%= render :partial => "pull_requests/new" %> diff --git a/app/views/pull_requests/index.html.erb b/app/views/pull_requests/index.html.erb index 37ea937fd..56d72c5ce 100644 --- a/app/views/pull_requests/index.html.erb +++ b/app/views/pull_requests/index.html.erb @@ -18,7 +18,7 @@ <%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%>
- #5 · <%= link_to request.author.try(:username), user_path(request.author), :class => "link-blue" %> 创建于<%= time_tag(request.created_at) %> + <%= 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) %>更新 diff --git a/app/views/pull_requests/new.html.erb b/app/views/pull_requests/new.html.erb index 3d3f9af61..e77c2d364 100644 --- a/app/views/pull_requests/new.html.erb +++ b/app/views/pull_requests/new.html.erb @@ -1,83 +1,2 @@ <%= render :partial => "pull_requests/pull_request_container" %> -99 | -99 | -<% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %> | -
100 | -100 | -<div class="mt10"> | -
111 | -- | - <div class="fl mr5 fontGrey3"> | -
- | 111 | -+ <div class="fl mr20 fontGrey3 w80"> | -
Pull Request
<%= @request.description %>