Merge branch 'dev_newproject' into develop

This commit is contained in:
huang 2016-11-18 16:22:03 +08:00
commit de61d699a8
25 changed files with 305 additions and 265 deletions

View File

@ -1,9 +1,10 @@
# 如果你对改模块任何功能不清楚,请不要随便改
# @Hjqreturn
class PullRequestsController < ApplicationController
before_filter :authorize_logged
before_filter :find_project_and_repository
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new,
:update_pull_request, :pull_request_comments, :create_pull_request_comment]
:update_pull_request, :pull_request_comments, :create_pull_request_comment, :compare_pull_request]
layout "base_projects"
include PullRequestsHelper
@ -46,10 +47,11 @@ class PullRequestsController < ApplicationController
end
# 主要取源项目和目标项目分支及标识(用户名/版本库名)
# @tip 为空的时候表明发送的pr请求有改动为1的时候源分支和目标分支没有改动则不能成功创建
def new
# project_menu_type 为了控制base顶部导航
@project_menu_type = 6
@tip = params[:show_tip]
identifier = get_rep_identifier_by_project @project
@source_project_name = "#{get_user_name(@project.user_id)}/#{identifier}"
@source_rev = @g.branches(@project.gpid).map{|b| b.name}
@ -84,17 +86,26 @@ class PullRequestsController < ApplicationController
description = params[:description]
source_branch = params[:source_branch]
target_branch = params[:target_branch]
target_project_id = params[:target_project_id]
begin
# 如果传送了目标项目ID则PR请求发至目标项目
if params[:forked_project_id] && params[:source_project] == "forked_project_name"
target_project_id = params[:forked_project_id].to_i
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id)
@fork_project_name = Project.find(@project.forked_from_project_id).try(:name)
@fork_pr_message = true if @fork_project_name
# 如果分支有改动
if compare_pull_request(source_branch, target_project_id, target_branch)
# 如果传送了目标项目ID即向fork源项目发送请求
if params[:forked_project_id] && params[:source_project] == "forked_project_name"
target_project_id = params[:forked_project_id].to_i
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id)
@fork_project_name = Project.find(@project.forked_from_project_id).try(:name)
@fork_pr_message = true if @fork_project_name
else
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
respond_to do |format|
format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)}
end
end
else
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
tip = 1
respond_to do |format|
format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)}
format.js{redirect_to new_project_pull_request_path(:show_tip => tip)}
end
end
rescue Exception => e
@ -102,8 +113,31 @@ class PullRequestsController < ApplicationController
end
end
# Compare branch for MR
# 判断源分支和目标分支是否有改动
# status 为true 表示有改动; false:便是没有改动
def compare_pull_request source_branch, target_project, target_branch
user_name_source = @project.owner.try(:login)
identifier = @repository.identifier.downcase
git_source_tree = '--git-dir=/home/git/repositories/' + user_name_source + '/' + identifier + '.git'
if target_project
forked_source_project = Project.find(target_project)
user_name_target = forked_source_project.owner.try(:login)
git_target_tree = '--git-dir=/home/git/repositories/' + user_name_target + '/' + identifier + '.git'
git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch)
git_target_commit_id = @g.get_branch_commit_id(forked_source_project.gpid, git_target_tree, target_branch)
else
git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch)
git_target_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, target_branch)
end
status = (git_sourse_commit_id.try(:commit_id) == git_target_commit_id.try(:commit_id) ? false : true)
end
# @project_menu_type 为了控制base顶部导航
# merge_when_succeeds
def show
# project_menu_type 为了控制base顶部导航
# compare_pull_request source_project, source_branch, target_project, target_branch
# compare_pull_request
@project_menu_type = 6
@type = params[:type]
@request = @g.merge_request(@project.gpid, params[:id])
@ -266,7 +300,7 @@ class PullRequestsController < ApplicationController
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")
@repository = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").first
rescue ActiveRecord::RecordNotFound
render_404
end

View File

@ -6,10 +6,10 @@ class QualityAnalysisController < ApplicationController
layout "base_projects"
include ApplicationHelper
include QualityAnalysisHelper
# require 'jenkins_api_client'
# require 'nokogiri'
# require 'json'
# require 'open-uri'
require 'jenkins_api_client'
require 'nokogiri'
require 'json'
require 'open-uri'
def show

View File

@ -102,7 +102,8 @@ class RepositoriesController < ApplicationController
g = Gitlab.client
if User.current.gid.nil?
begin
g.sync_user(User.current)
s = Trustie::Gitlab::Sync.new
s.sync_user(User.current)
ensure
logger.error "Synv user failed ==>#{User.current.id}"
end

View File

@ -931,7 +931,10 @@ module ApplicationHelper
def allow_pull_request project
return 0 if project.gpid.nil?
g = Gitlab.client
count = g.user_static(project.gpid, :rev => "master").count
# 之所以这样比较是为了解决gitlab本身的bug
commit_count = g.project(project.gpid).try(:commit_count).to_i
git_commit_cout = g.user_static(project.gpid, :rev => "master").count
count = commit_count > git_commit_cout ? commit_count : git_commit_cout
count
end

View File

@ -20,6 +20,8 @@
module IssuesHelper
include ApplicationHelper
include TagsHelper
require 'iconv'
def issue_list(issues, &block)
ancestors = []
issues.each do |issue|
@ -119,10 +121,11 @@ module IssuesHelper
end
def principals_options_for_isuue_list(project)
conv = Iconv.new("GBK", "utf-8")
if User.current.member_of?(project)
project.members.includes(:user).order("lower(users.login)").map{|c| [User.find(c.user_id).show_name, c.user_id]}.unshift(["<< #{l(:label_me)} >>", User.current.id]).unshift(["指派给", 0])
project.members.includes(:user).sort{|x, y| conv.iconv(x.user.lastname) <=> conv.iconv(y.user.lastname)}.map{|c| [User.find(c.user_id).show_name, c.user_id]}.unshift(["<< #{l(:label_me)} >>", User.current.id]).unshift(["指派给", 0])
else
project.members.includes(:user).order("lower(users.login)").map{|c| [User.find(c.user_id).show_name, c.user_id]}.unshift(["指派给", 0])
project.members.includes(:user).sort{|x, y| conv.iconv(x.user.lastname) <=> conv.iconv(y.user.lastname)}.map{|c| [User.find(c.user_id).show_name, c.user_id]}.unshift(["指派给", 0])
end
end
@ -130,7 +133,6 @@ module IssuesHelper
versions = Version.where(:project_id => project, :status => "open").map{|version| [version.name, version.id]}.unshift(["里程碑", 0])
end
def render_issue_subject_with_tree(issue)
s = ''
ancestors = issue.root? ? [] : issue.ancestors.visible.all

View File

@ -1,5 +1,5 @@
class Dts < ActiveRecord::Base
attr_accessible :Category, :Defect, :Description, :File, :IPLine, :IPLineCode, :Method, :Num, :PreConditions, :Review, :StartLine, :TraceInfo, :Variable, :project_id
belongs_to :project
# belongs_to :project
end

View File

@ -853,7 +853,8 @@ class Issue < ActiveRecord::Base
def assignable_versions
return @assignable_versions if @assignable_versions
versions = project.shared_versions.open.all
# versions = project.shared_versions.open.all
versions = Version.where(:project_id => project.id, :status => "open").order("created_on desc")
if fixed_version
if fixed_version_id_changed?
# nothing to do
@ -865,7 +866,7 @@ class Issue < ActiveRecord::Base
versions << fixed_version
end
end
@assignable_versions = versions.uniq.sort
@assignable_versions = versions.uniq
end
# Returns true if this issue is blocked by another issue that is still open

View File

@ -82,7 +82,7 @@ class Project < ActiveRecord::Base
has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy
has_many :applied_projects, :dependent => :destroy
has_many :invite_lists, :dependent => :destroy
has_one :dts
# has_one :dts
has_many :organizations,:through => :org_projects
# end

View File

@ -41,7 +41,7 @@
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
</div>
<%= form_tag(edit_file_description_project_file_path(file, :project_id => project.id),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %>
<textarea style="resize: none;max-width: none;margin-left: 0" class="homepageSignatureTextarea W600 none " placeholder="请编辑资源描述" name="file_description_edit" id="file_description_edit_<%= file.id %>"
<textarea style="resize: none;max-width: none;margin-left: 0" class="homepageSignatureTextarea W800 none " placeholder="请编辑资源描述" name="file_description_edit" id="file_description_edit_<%= file.id %>"
onblur="commit_files_description('#files_query_form_<%= file.id %>','#file_description_edit_<%= file.id %>','#file_description_show_<%= file.id %>','#file_description_tip_<%= file.id %>');"><%= file.description %></textarea>
<% end %>
</div>

View File

@ -160,5 +160,9 @@
}
// 里程碑添加默认选项
$("#issue_fixed_version_id option[value='']").remove();
$('#issue_fixed_version_id').prepend("<option value='0' selected='selected'>选择里程碑</option>")
<% if params[:action] == "new" %>
$('#issue_fixed_version_id').prepend("<option value='0' selected='selected'>选择里程碑</option>")
<% else %>
$('#issue_fixed_version_id').prepend("<option value='0'>选择里程碑</option>")
<% end %>
</script>

View File

@ -12,9 +12,9 @@
<% if @forked_project.nil? %>
<%= select_tag :branch, options_for_select(@source_rev), :id => "pull_request_branch", :name => "target_branch", :value => "target_branch",:class => "fl PullReques_minselect ml5" %>
<% else %>
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" id="pull_request_project" name="source_project" value="source_project" class="fl PullReques_minselect">
<option name="<%= @project.id %>" value="source_project_name" ><%= @source_project_name %></option>
<option name="<%= @forked_project.id %>" value="forked_project_name" ><%= @forked_project_name %></option>
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" id="target_project_id" name="target_project_id" value="target_project_id" class="fl PullReques_minselect">
<option id="source_project_name" name="<%= @project.id %>" value="<%= @project.id %>" ><%= @source_project_name %></option>
<option id="target_project_name" name="<%= @forked_project.id %>" value="<%= @forked_project.id %>" ><%= @forked_project_name %></option>
</select>
<select name="target_branch" id="pull_request_branch" class = "fl PullReques_minselect ml5" >
<% @source_rev.each do |rev| %>
@ -23,7 +23,11 @@
</select>
<% end %>
<p id="pull_request_project_hidden" style="display: none"><%= @forked_project.nil? ? "" : @project.id %></p>
<p id="pull_request_compare_result" style="display: none"><%= @no_updates %></p>
</li>
<div id="pull_request_branch_tip">
<%= render :partial => "tip" %>
</div>
<div class="alert alert-blue mb10" id ="pull_request_branch_error" style="display: none">
<span class="c_orange">您选择的源分支和目标分支为似乎没有差异,请将新改动提交至源分支或者切换到其它目标分支</span>
</div>
@ -63,28 +67,41 @@
}
}
function regex_branch()
{
var source_branch = $.trim($("#source_branch").val());
var target_branch = $.trim($("#pull_request_branch").val());
var target_project = $.trim($("#pull_request_project").children().attr("name"));
var target_forked_project = $.trim($("#pull_request_project_hidden").text());
if(target_project == target_forked_project && source_branch == target_branch)
{
$("#pull_request_branch_error").show();
return false;
}
else
{
$("#pull_request_branch_error").hide();
return true;
}
}
// function regex_branch()
// {
// var source_branch = $.trim($("#source_branch").val());
// var target_branch = $.trim($("#pull_request_branch").val());
// var target_project = $.trim($("#target_project_id").children().attr("name"));
// var target_forked_project = $.trim($("#pull_request_project_hidden").text());
// if(target_project == target_forked_project && source_branch == target_branch)
// {
// $("#pull_request_branch_error").show();
// return false;
// }
// else
// {
// $("#pull_request_branch_error").hide();
// return true;
// }
// }
// function compare_can_create(){
// var compare_result = $.trim($("#pull_request_compare_result").text());
// alert(compare_result);
// if(compare_result == 1){
// alert(compare_result);
// $("#pull_request_branch_error").show();
// return false;
// }else{
// $("#pull_request_branch_error").hide();
// return true;
// }
// }
//提交pull request
function pull_request_commit()
{
if(regex_branch() && regex_pr_name())
if(regex_pr_name())
{
$("#pull_request_form").submit();
}

View File

@ -0,0 +1,5 @@
<% if @tip %>
<div class="alert alert-blue mb10">
<span class="c_orange">您选择的源分支和目标分支为似乎没有差异,请将新改动提交至源分支或者切换到其它目标分支</span>
</div>
<% end %>

View File

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

View File

@ -0,0 +1,10 @@
<div class="quality_info mb10">
<h2>
<% if @name_flag || params[:action] == "error_list" %>
<%= link_to "<span class='new_roadmap_icons_back mr5'></span>返回".html_safe, {:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)}, :class => "fl linkBlue2 mr5 mt1" %>
<% else %>
<%= link_to "<span class='new_roadmap_icons_back mr5'></span>返回".html_safe, project_quality_analysis_path(:project_id => @project.id), :class => "fl linkBlue2 mr5 mt1" %>
<% end %>
<span class="fl mr5">|</span> <span class="fl mt1">分析结果</span>
</h2>
</div>

View File

@ -2,75 +2,39 @@
// $("#ajax-indicator span").text("载入中...");
$("#ajax-indicator").show();
</script>
<div class="quality_info mb10">
<h2><a href="javascript:history.go(-1)" class="fl linkBlue2 mr5" >
<span class="new_roadmap_icons_back mr5"></span>
返回</a> <span class="fl mr5">|</span> <span class="fl">分析结果</span>
</h2>
</div>
<%= render :partial => "header" %>
<div class="container-big mb10">
<table>
<tbody>
<tr>
<td>名称</td>
<td>分支</td>
<td>语言</td>
<td>路径</td>
<td>时间</td>
<td></td>
</tr>
</tbody>
<tbody>
<% if @quality_analyses && @quality_analyses.count > 0 %>
<% @quality_analyses.each do |qa| %>
<tr>
<td></td>
<td><%= qa.branch %></td>
<td><%= qa.language %></td>
<td><%= qa.path %></td>
<td><%= format_time(qa.created_at) %></td>
<td><%=link_to "删除", delete_project_quality_analysi_path(qa, :project_id => @project.id), :method => "delete", :confirm => "删除会一并删除分析结果,确定删除吗?", :class => "fontBlue2" %></td>
</tr>
<% end %>
<% else %>
<% end %>
</tbody>
</table>
</div>
<div class="container-big mb10">
<div class="project_r_h" style="width:970px;">
<h2 class="project_h2">分析结果</h2>
</div>
<ul class="analysis-result-list">
<li class="analysis-result-name fl fontBlue2" >名称</li>
<li class="analysis-result-version fl fontBlue2" >分支</li>
<li class="analysis-result-loc fl fontBlue2" >语言</li>
<li class="analysis-result-debt fl fontBlue2" >路径</li>
<li class="analysis-result-time fl fontBlue2" >最近更新</li>
<li class="analysis-result-edit fl fontBlue2" ></li>
<div class="cl"></div>
</ul>
<% if @quality_analyses && @quality_analyses.count >0 %>
<table class="sy_new_table " cellpadding="0" cellspacing="0">
<thead>
<tr>
<td style="width:15%;">名称</td>
<td style="width:10%;">分支</td>
<td style="width:10%;">语言</td>
<td style="width:25%;">路径</td>
<td style="width:20%;">时间</td>
<td style="width:10%;"></td>
</tr>
</thead>
<tbody>
<% if @quality_analyses && @quality_analyses.count > 0 %>
<% @quality_analyses.each do |qa| %>
<ul class="analysis-result-list">
<li title="<%= qa.author_login+ ':' +qa.rep_identifier %>"><%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %></li>
<li class="analysis-result-version fl fontBlue2 hidden" title="<%= qa.branch %>"><%= qa.branch %></li>
<li class="analysis-result-loc fl fontBlue2 hidden" title="<%= qa.language %>"><%= qa.language %></li>
<li class="analysis-result-debt fl fontBlue2 hidden" title="<%= qa.path %>"><%= qa.path %></li>
<li class="analysis-result-time fl fontBlue2 hidden" title="<%= sonar_time(qa.sonar_name).blank? ? qa.created_at : sonar_time(qa.sonar_name) %>"><%= format_time(sonar_time(qa.sonar_name).blank? ? qa.created_at : sonar_time(qa.sonar_name)) %></li>
<tr>
<td style="width:15%;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" title="<%= qa.sonar_name %>"><%=link_to qa.sonar_name, project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2 hidden" %></td>
<td style="width:10%;"><%= qa.branch %></td>
<td style="width:10%;"><%= qa.language %></td>
<td style="width:25%;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" title="<%= qa.path %>"><%= qa.path %></td>
<td style="width:20%;"><%= format_time(qa.created_at) %></td>
<% if User.current.try(:login) == qa.author_login || User.current.admin? || is_project_manager?(User.current.id, @project.id) %>
<li class="analysis-result-edit fl fontBlue2 hidden" title="<%= qa.path %>">
<%=link_to "删除", delete_project_quality_analysi_path(qa, :project_id => @project.id), :method => "delete", :confirm => "删除会一并删除分析结果,确定删除吗?", :class => "fontBlue2" %>
</li>
<td style="width:10%;"><%=link_to "删除", delete_project_quality_analysi_path(qa, :project_id => @project.id), :method => "delete", :confirm => "删除会一并删除分析结果,确定删除吗?", :class => "fontBlue2" %></td>
<% else %>
<td style="width:10%;" class="c_grey"><%= "删除" %></td>
<% end %>
<div class="cl"></div>
</ul>
</tr>
<% end %>
<% else %>
<%#= 数据为空时候界面,待完善 %>
<% end %>
</tbody>
</table>
</div>

View File

@ -1,63 +1,61 @@
<%= javascript_include_tag 'highcharts','highcharts-more' %>
<%= render :partial => "header" %>
<div class="container-big mb10">
<div class="project_r_h" style="width:970px;">
<h2 class="project_h2" style="width:180px;">质量分析</h2>
</div>
<div class="button-rep">当前分支:<%= params[:branch] %></div>
<div class="cl"></div>
<div class="tac f20 fb mt35 mb30">项目代码质量分析报告</div>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">概要信息</span></div>
<%= render :partial => "hightchars" %>
<div class="analysis-block mt10 mb40 f14">
<div class="flex mb10">
<div class="analysis-genral">
<p id="container_sqale_rating" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">质量等级</p>
<p class="fontBlue2 pr"><%= sqale_rating_status(@ha["sqale_rating"].to_i)[2] %>
<span class="f10 c_white analysis-genral-icon <%= sqale_rating_status(@ha["sqale_rating"].to_i)[1] %> borderRadius">
<div class="button-rep">当前分支:<%= params[:branch] %></div>
<div class="cl"></div>
<div class="tac f20 fb mt35 mb30">项目代码质量分析报告</div>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">概要信息</span></div>
<%= render :partial => "hightchars" %>
<div class="analysis-block mt10 mb40 f14">
<div class="flex mb10">
<div class="analysis-genral">
<p id="container_sqale_rating" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">质量等级</p>
<p class="fontBlue2 pr"><%= sqale_rating_status(@ha["sqale_rating"].to_i)[2] %>
<span class="f10 c_white analysis-genral-icon <%= sqale_rating_status(@ha["sqale_rating"].to_i)[1] %> borderRadius">
<%= @ha["sqale_rating"].nil? ? "很好" : sqale_rating_status(@ha["sqale_rating"].to_i)[0] %>
</span>
</p>
</div>
<div class="analysis-genral" >
<p id="container_function_complexity" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">复杂度</p>
<p class="fontBlue2 pr"><%= @ha["function_complexity"].to_i == 0 ? 0 : @ha["function_complexity"] %>
<span class="f10 c_white analysis-genral-icon <%= complexity_status(@ha["function_complexity"].to_i)[1] %> borderRadius">
</p>
</div>
<div class="analysis-genral" >
<p id="container_function_complexity" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">复杂度</p>
<p class="fontBlue2 pr"><%= @ha["function_complexity"].to_i == 0 ? 0 : @ha["function_complexity"] %>
<span class="f10 c_white analysis-genral-icon <%= complexity_status(@ha["function_complexity"].to_i)[1] %> borderRadius">
<%= @ha["function_complexity"].nil? ? "良好" : complexity_status(@ha["function_complexity"].to_i)[0] %>
</span>
</p>
</div>
<div class="analysis-genral">
<p id="container_duplicated_lines_density" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">代码重复度</p>
<p class="fontBlue2 pr"><%= @ha["duplicated_lines_density"].to_i == 0 ? 0 : @ha["duplicated_lines_density"] %>
<span class="f10 c_white analysis-genral-icon <%= duplicated_lines_density_status(@ha["duplicated_lines_density"].to_i)[1] %> borderRadius">
</p>
</div>
<div class="analysis-genral">
<p id="container_duplicated_lines_density" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">代码重复度</p>
<p class="fontBlue2 pr"><%= @ha["duplicated_lines_density"].to_i == 0 ? 0 : @ha["duplicated_lines_density"] %>
<span class="f10 c_white analysis-genral-icon <%= duplicated_lines_density_status(@ha["duplicated_lines_density"].to_i)[1] %> borderRadius">
<%= @ha["duplicated_lines_density"].nil? ? "良好" : duplicated_lines_density_status(@ha["duplicated_lines_density"].to_i)[0] %>
</span>
</p>
</div>
<div class="analysis-genral">
<p id="container_comment_lines_density" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">注释率</p>
<p class="fontBlue2 pr"><%= @ha["comment_lines_density"].to_i == 0 ? 0 : @ha["comment_lines_density"] %>
<span class="f10 c_white analysis-genral-icon <%= comment_lines_density_status(@ha["comment_lines_density"].to_i)[1] %> borderRadius">
</p>
</div>
<div class="analysis-genral">
<p id="container_comment_lines_density" style="max-width:200px;min-height:200px;width:200px; margin:0 auto;"></p>
<p class="fontGrey3">注释率</p>
<p class="fontBlue2 pr"><%= @ha["comment_lines_density"].to_i == 0 ? 0 : @ha["comment_lines_density"] %>
<span class="f10 c_white analysis-genral-icon <%= comment_lines_density_status(@ha["comment_lines_density"].to_i)[1] %> borderRadius">
<%= @ha["comment_lines_density"].nil? ? "较低" : comment_lines_density_status(@ha["comment_lines_density"].to_i)[0] %>
</span>
</p>
</div>
</p>
</div>
</div>
</div>
<div class="analysis-tag-wrap f16">
<span class="analysis-tag fl mr15"></span>
<span class="fb fl mr10">质量等级</span>
<span class="mr10 fontGrey2"><span class="c_red f18" style="margin-top:-5px; display:inline-block;"><%= @ha["sqale_rating"].nil? ? 0 : score_sqale_rating(@ha["sqale_rating"].to_i) %></span>/5分</span>
<span class="fontGrey2">可定性评价为:<span class="c_red">质量<%= @ha["sqale_rating"].nil? ? "很好" : sqale_rating_status(@ha["sqale_rating"].to_i)[0] %></span></span></div>
<div class="analysis-block mt10 mb40 f14">
<div><span class="fontGrey3 mr30">技术债务</span>
<div class="analysis-tag-wrap f16">
<span class="analysis-tag fl mr15"></span>
<span class="fb fl mr10">质量等级</span>
<span class="mr10 fontGrey2"><span class="c_red f18" style="margin-top:-5px; display:inline-block;"><%= @ha["sqale_rating"].nil? ? 0 : score_sqale_rating(@ha["sqale_rating"].to_i) %></span>/5分</span>
<span class="fontGrey2">可定性评价为:<span class="c_red">质量<%= @ha["sqale_rating"].nil? ? "很好" : sqale_rating_status(@ha["sqale_rating"].to_i)[0] %></span></span></div>
<div class="analysis-block mt10 mb40 f14">
<div><span class="fontGrey3 mr30">技术债务</span>
<span class="w100 pInline">
<% if @ha["sqale_index"].to_i == 0 %>
0天
@ -66,97 +64,97 @@
<%= / [0-9]*/.match(@ha["sqale_index"]).nil? ? "" : (/ [0-9]*/.match(@ha["sqale_index"]).to_s + "小时") %>
<% end %>
</span>
<span class="fontGrey2"><a class="linkBlue2" target="_blank" href="<%= @sonar_address %>/drilldown/measures/<%= @resource_id %>?metric=sqale_index">查看详情</a></span></div>
<div><span class="fontGrey3 mr30 fl">&nbsp;质量问题</span>
<span class="fontGrey2"><a class="linkBlue2" target="_blank" href="<%= @sonar_address %>/drilldown/measures/<%= @resource_id %>?metric=sqale_index">查看详情</a></span></div>
<div><span class="fontGrey3 mr30 fl">&nbsp;质量问题</span>
<span class="fontBlue2 w100 pInline">
<a class="fontBlue2 w70 pInline" target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false">
<%= @ha["violations"].to_i %>
</a>
</span><span class="fontGrey2">&nbsp;问题分类如下:</span></div>
<div class="ml90 mt15">
<div class="mb10"><span class="analysis-block-icon mr5"></span><span class="fontGrey3 mr45">阻断</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=BLOCKER" class="fontBlue2 w70 pInline">
<%= @ha["blocker_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%=@ha["blocker_violations"].nil? ? 0 : statistics_result_percentage(@ha["blocker_violations"].to_i, 3000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-serious-icon mr5"></span><span class="fontGrey3 mr45">严重</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=CRITICAL" class="fontBlue2 w70 pInline">
<%= @ha["critical_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= @ha["critical_violations"].nil? ? 0 : statistics_result_percentage(@ha["critical_violations"].to_i, 3000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-main-icon mr5"></span><span class="fontGrey3 mr45">主要</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=MAJOR" class="fontBlue2 w70 pInline">
<%= @ha["major_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= @ha["major_violations"].nil? ? 0 : statistics_result_percentage(@ha["major_violations"].to_i, 3000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-secondary-icon mr5"></span><span class="fontGrey3 mr45">次要</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=MINOR" class="fontBlue2 w70 pInline">
<%= @ha["minor_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= @ha["minor_violations"].nil? ? 0 : statistics_result_percentage(@ha["minor_violations"].to_i, 3000) %>%;"></span></span></div>
<div><span class="analysis-info-icon mr5"></span><span class="fontGrey3 mr45">信息</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=INFO" class="fontBlue2 w70 pInline">
<%= @ha["info_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= @ha["info_violations"].nil? ? 0 : statistics_result_percentage(@ha["info_violations"].to_i, 3000) %>%;"></span></span></div>
</div>
<div class="ml90 mt15">
<div class="mb10"><span class="analysis-block-icon mr5"></span><span class="fontGrey3 mr45">阻断</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=BLOCKER" class="fontBlue2 w70 pInline">
<%= @ha["blocker_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%=@ha["blocker_violations"].nil? ? 0 : statistics_result_percentage(@ha["blocker_violations"].to_i, 3000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-serious-icon mr5"></span><span class="fontGrey3 mr45">严重</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=CRITICAL" class="fontBlue2 w70 pInline">
<%= @ha["critical_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= @ha["critical_violations"].nil? ? 0 : statistics_result_percentage(@ha["critical_violations"].to_i, 3000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-main-icon mr5"></span><span class="fontGrey3 mr45">主要</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=MAJOR" class="fontBlue2 w70 pInline">
<%= @ha["major_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= @ha["major_violations"].nil? ? 0 : statistics_result_percentage(@ha["major_violations"].to_i, 3000) %>%;"></span></span></div>
<div class="mb10"><span class="analysis-secondary-icon mr5"></span><span class="fontGrey3 mr45">次要</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=MINOR" class="fontBlue2 w70 pInline">
<%= @ha["minor_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= @ha["minor_violations"].nil? ? 0 : statistics_result_percentage(@ha["minor_violations"].to_i, 3000) %>%;"></span></span></div>
<div><span class="analysis-info-icon mr5"></span><span class="fontGrey3 mr45">信息</span>
<a target="_blank" href="<%= @sonar_address %>/component_issues?id=<%= @resource_id %>#resolved=false|severities=INFO" class="fontBlue2 w70 pInline">
<%= @ha["info_violations"].to_i %>
</a>
<span class="quality-percentage"><span class="quality-percentage-rate" style="width:<%= @ha["info_violations"].nil? ? 0 : statistics_result_percentage(@ha["info_violations"].to_i, 3000) %>%;"></span></span></div>
</div>
<div class="analysis-tag-wrap f16">
<span class="analysis-tag fl mr15"></span>
<span class="fb fl mr10">代码规模</span><span class="fontGrey2">可定性评价为:<span class="c_red"><%= @ha["lines"].nil? ? 0 : lines_scale(@ha["lines"].to_i) %></span></span></div>
<div class="analysis-block mt10 mb40 flex f14">
<div class="analysis-genral">
<p class="fontGrey3">代码行数</p>
<p class="fontBlue2"><%= @ha["lines"].to_i %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">文件</p>
<p class="fontBlue2"><%= @ha["files"].to_i %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">目录</p>
<p class="fontBlue2"><%= @ha["directories"].to_i %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">类</p>
<p class="fontBlue2"><%= @ha["classes"].to_i %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">方法</p>
<p class="fontBlue2"><%= @ha["functions"].to_i %></p>
</div>
</div>
<div class="analysis-tag-wrap f16">
<span class="analysis-tag fl mr15"></span>
<span class="fb fl mr10">代码规模</span><span class="fontGrey2">可定性评价为:<span class="c_red"><%= @ha["lines"].nil? ? 0 : lines_scale(@ha["lines"].to_i) %></span></span></div>
<div class="analysis-block mt10 mb40 flex f14">
<div class="analysis-genral">
<p class="fontGrey3">代码行数</p>
<p class="fontBlue2"><%= @ha["lines"].to_i %></p>
</div>
<% if !@user_quality_infos.blank? %>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">贡献统计</span></div>
<div class="analysis-block mt10 f12">
<ul class="contribute-list">
<li class="fl fontGrey2 contribute-list-avatar">&nbsp;</li>
<li class="fl fontGrey2 contribute-list-code">代码行数</li>
<li class="fl fontGrey2 contribute-list-problem">引入质量问题总数</li>
<li class="fl fontGrey2 contribute-list-problem">未解决质量问题数</li>
<li class="fl fontGrey2 contribute-list-rate">引入质量问题数/代码行数</li>
<div class="cl"></div>
</ul>
<div class="analysis-genral">
<p class="fontGrey3">文件</p>
<p class="fontBlue2"><%= @ha["files"].to_i %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">目录</p>
<p class="fontBlue2"><%= @ha["directories"].to_i %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">类</p>
<p class="fontBlue2"><%= @ha["classes"].to_i %></p>
</div>
<div class="analysis-genral">
<p class="fontGrey3">方法</p>
<p class="fontBlue2"><%= @ha["functions"].to_i %></p>
</div>
</div>
<% if !@user_quality_infos.blank? %>
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">贡献统计</span></div>
<div class="analysis-block mt10 f12">
<ul class="contribute-list">
<li class="fl fontGrey2 contribute-list-avatar">&nbsp;</li>
<li class="fl fontGrey2 contribute-list-code">代码行数</li>
<li class="fl fontGrey2 contribute-list-problem">引入质量问题总数</li>
<li class="fl fontGrey2 contribute-list-problem">未解决质量问题数</li>
<li class="fl fontGrey2 contribute-list-rate">引入质量问题数/代码行数</li>
<div class="cl"></div>
</ul>
<% @user_quality_infos.each do |author_info| %>
<% user = get_user_by_mail(author_info[:email]) %>
<%# unless author_info[:changes] == 0 %>
<ul class="contribute-list">
<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">
<div class="mt8">
<%=link_to image_tag(url_to_avatar(user), :width => "50", :height => "50", :class => "image-cir"), user_path(user), :target => '_blank' %>
<p class="fontGrey2 hidden"><%=link_to (user.id == 2 ? author_info[:email] : user.show_name), user_path(user) %></p>
</div>
</li>
<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height"><%= author_info[:changes] %></li>
<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height"><%= author_info[:all_issue_count] %></li>
<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height c_red"><%= author_info[:unresolved_issue_count] %></li>
<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height"><%= author_info[:ratio] %></li>
<div class="cl"></div>
</ul>
<%# end %>
<% end %>
<% @user_quality_infos.each do |author_info| %>
<% user = get_user_by_mail(author_info[:email]) %>
<%# unless author_info[:changes] == 0 %>
<ul class="contribute-list">
<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">
<div class="mt8">
<%=link_to image_tag(url_to_avatar(user), :width => "50", :height => "50", :class => "image-cir"), user_path(user), :target => '_blank' %>
<p class="fontGrey2 hidden"><%=link_to (user.id == 2 ? author_info[:email] : user.show_name), user_path(user) %></p>
</div>
</li>
<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height"><%= author_info[:changes] %></li>
<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height"><%= author_info[:all_issue_count] %></li>
<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height c_red"><%= author_info[:unresolved_issue_count] %></li>
<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height"><%= author_info[:ratio] %></li>
<div class="cl"></div>
</ul>
<%# end %>
<% end %>
</div>
<% end %>
</div>
<% end %>
</div>

View File

@ -1,7 +1,5 @@
<%= render :partial => "header" %>
<div class="container-big mb10">
<div class="project_r_h">
<h2 class="project_h2" style="width:180px;">质量分析</h2>
</div>
<div>
<div class="c_red">本次分析失败,原因如下:</div>
<% if @build_console_result == false %>

View File

@ -1,7 +1,7 @@
<% member = Member.where("user_id = #{@user.id} and project_id = #{project.id}").first %>
<% if User.current == @user %>
<% if member %>
<%= link_to "", cancel_or_collect_user_path(@user, :project => project.id), :class => "#{member.is_collect == 1 ? 'icons_project_favorite mt3' : 'icons_project_star mt3'}",:target => '_blank', :remote => true, :title => "#{member.is_collect == 1 ? '点击将其从个人主页的班级列表中移除' : '点击将其添加至个人主页的班级列表中'}" %>
<%= link_to "", cancel_or_collect_user_path(@user, :project => project.id), :class => "#{member.is_collect == 1 ? 'icons_project_favorite mt3' : 'icons_project_star mt3'}",:target => '_blank', :remote => true, :title => "#{member.is_collect == 1 ? '点击将其从个人主页的项目列表中移除' : '点击将其添加至个人主页的项目列表中'}" %>
<% end %>
<% else %>
<% if member %>

View File

@ -19,7 +19,7 @@
<li class="f14"><strong>项目消息</strong></li>
<li><%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "homepageTypePTask postTypeGrey" %></li>
<li><%= link_to "项目讨论", user_message_path(User.current, :type => 'forge_message'), :class => "homepagePostTypeForum postTypeGrey" %></li>
<li><%= link_to "项目新闻", user_message_path(User.current, :type => 'forge_news'), :class => "homepageTypePNews postTypeGrey" %></li>
<!--<li><%#= link_to "项目新闻", user_message_path(User.current, :type => 'forge_news'), :class => "homepageTypePNews postTypeGrey" %></li>-->
<li><%= link_to "加入项目", user_message_path(User.current, :type => 'apply'), :class => "homepageTypeUApply postTypeGrey" %></li>
</ul>
</li>

View File

@ -164,25 +164,6 @@
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.forge_message_type == "News" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.forge_message.author), :width => "30", :height => "30"), user_path(ma.forge_message.author), :target => '_blank' %></a>
</li>
<li class="homepageNewsPubType fl">
<%=link_to ma.forge_message.author, user_path(ma.forge_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布了新闻:</span>
</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ("#{ma.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ma.forge_message.id},
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
<!--:onmouseover => "message_titile_show($(this),event)",-->
<!--:onmouseout => "message_titile_hide($(this))" %>-->
</a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.forge_message_type == "Comment" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.forge_message.author), :width => "30", :height => "30"), user_path(ma.forge_message.author), :target => '_blank' %></a></li>

View File

@ -0,0 +1,8 @@
class RemoveColumnToProjects < ActiveRecord::Migration
def up
remove_column :projects, :commits_count, :issues_count, :attachments_count, :boards_count, :news_count, :acts_count, :journals_count, :boards_reply_count
end
def down
end
end

View File

@ -86,6 +86,11 @@ class Gitlab::Client
get("/projects/#{project}/repository/user_static", :query => options)
end
def get_branch_commit_id(project, git_tree, ref_name)
get("/projects/#{project}/repository/get_branch_commit_id?git_tree=#{git_tree}&ref_name=#{ref_name}")
end
# Gets a specific commit identified by the commit hash or name of a branch or tag.
#
# @example

View File

@ -331,6 +331,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.W600{ width:600px !important;}
.W700{ width:700px; max-width:700px; min-width:700px;}
.W710{ width:708px;}
.W800{ width:800px !important;}
.maxwidth150{max-width: 150px;}
.m_w460{max-width: 460px;}
.m_w500{max-width: 500px;}

View File

@ -1035,3 +1035,9 @@ a:hover.pro_new_users {color: #3b94d6}
/*质量分析*/
.quality_info{ border:1px solid #ddd; background-color:#fff; width: 998px;}
.quality_info h2{ background: #fff; font-size: 14px; color: #333; height: 40px; line-height: 40px; padding-left: 15px; border-bottom:1px solid #e5e5e5;}
table.quality_list{ border:none; border-collapse: collapse; width: 100%; margin-bottom: 4px; }
table.quality_list tbody td, table.quality_list tbody tr td {
border-bottom: solid 1px #ddd;
font-size: 11px;
padding: 4px 10px 4px 3px;
}

View File

@ -1289,3 +1289,4 @@ a.pages-big{ width:50px;}
.W420 {width:420px;}
.W300 {width:300px !important;}
.W600{ width:600px;}