Merge branch 'rep_quality' of https://git.trustie.net/jacknudt/trustieforge into rep_quality
This commit is contained in:
commit
65d4af1307
|
@ -1,25 +1,63 @@
|
||||||
class PullRequestsController < ApplicationController
|
class PullRequestsController < ApplicationController
|
||||||
before_filter :find_project_and_repository
|
before_filter :find_project_and_repository
|
||||||
before_filter :connect_gitlab, :only => [:index, :show]
|
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pr]
|
||||||
|
|
||||||
layout "base_projects"
|
layout "base_projects"
|
||||||
|
|
||||||
|
# 返回json格式
|
||||||
def index
|
def index
|
||||||
results = @g.merge_requests(@project.gpid)
|
@requests = @g.merge_requests(@project.gpid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
||||||
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
|
def create
|
||||||
|
title = params[:title]
|
||||||
|
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
||||||
end
|
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_pr
|
||||||
|
commit_id = parmas[:commit_id]
|
||||||
|
status = @g.accept_pull_rquest(@project.gpid, commit_id)
|
||||||
|
if status == '200'
|
||||||
|
# 需跳入的地方
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def connect_gitlab
|
def connect_gitlab
|
||||||
@g = Gitlab.client
|
@g = Gitlab.client
|
||||||
|
|
|
@ -809,6 +809,7 @@ RedmineApp::Application.routes.draw do
|
||||||
collection do
|
collection do
|
||||||
end
|
end
|
||||||
member do
|
member do
|
||||||
|
post 'accept_pr'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,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_pull_rquest(project, id)
|
||||||
|
put("/projects/#{project}/merge_request/#{id}/merge")
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_attributes!(options, attrs)
|
def check_attributes!(options, attrs)
|
||||||
|
|
Loading…
Reference in New Issue