Merge branch 'rep_quality' of https://git.trustie.net/jacknudt/trustieforge into rep_quality
This commit is contained in:
commit
e33bbfff3f
|
@ -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/
|
|
@ -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/
|
|
@ -0,0 +1,36 @@
|
|||
class PullRequestsController < ApplicationController
|
||||
before_filter :find_project_and_repository
|
||||
before_filter :connect_gitlab, :only => [:index, :show]
|
||||
|
||||
layout "base_projects"
|
||||
|
||||
def index
|
||||
results = @g.merge_requests(@project.gpid)
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
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
|
|
@ -1,17 +1,30 @@
|
|||
class PullRquestsController < ApplicationController
|
||||
before_filter :find_project
|
||||
before_filter :find_project_and_repository
|
||||
before_filter :connect_gitlab, :only => [:index, :show]
|
||||
|
||||
layout "base_projects"
|
||||
|
||||
def index
|
||||
|
||||
results = @g.merge_requests(@project.gpid)
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def find_project
|
||||
def create
|
||||
|
||||
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
|
||||
|
|
|
@ -814,6 +814,18 @@ module ApplicationHelper
|
|||
return @result
|
||||
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
|
||||
def rep_is_gitlab?(project)
|
||||
rep = project.repositories.where("type =?", "Repository::Gitlab")
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
module PullRequestsHelper
|
||||
end
|
|
@ -57,11 +57,11 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<!-- more -->
|
||||
<% if User.current.member_of?(@project) %>
|
||||
<% if allow_pull_request(@project) %>
|
||||
<div class="subNav">
|
||||
<%= link_to "Pull Requests", project_files_path(@project), :class => "f14 c_blue02" %>
|
||||
<%= link_to "Pull Requests", project_pull_requests_path(@project), :class => "f14 c_blue02" %>
|
||||
<% unless @project.project_score.attach_num == 0 %>
|
||||
<%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
|
||||
<%#= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -805,7 +805,7 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :pull_rquests do
|
||||
resources :pull_requests do
|
||||
collection do
|
||||
end
|
||||
member do
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PullRequestsController, :type => :controller do
|
||||
|
||||
end
|
Loading…
Reference in New Issue