解决部分项目提交数为0的问题,版本库登录名改成中文姓名

This commit is contained in:
huang 2016-11-01 14:54:29 +08:00
parent e8b116bdb1
commit f0a713f54e
4 changed files with 10 additions and 5 deletions

View File

@ -671,7 +671,7 @@ class ProjectsController < ApplicationController
g = Gitlab.client
begin
result = g.rep_last_changes(gpid, :rev => rev, :path => ent_path)
result = {:message => result.message, :author_name => result.author_name, :time => distance_of_time_in_words(result.time, Time.now)}
result = {:message => result.message, :author_name => User.find_by_login(result.author_name).nil? ? result.author_name : User.find_by_login(result.author_name).show_name, :time => distance_of_time_in_words(result.time, Time.now)}
rescue Exception => e
puts e
end

View File

@ -27,6 +27,11 @@ module RepositoriesHelper
REPO_IP_ADDRESS = Setting.host_repository
REPO_GITLAB_ADDRESS = "git.trustie.net"
# 因为gitlab的提交总数不是实时同步的说以取总数用两种方法
def choise_commit_count git_count, pro_count
git_count > pro_count ? git_count : pro_count
end
# 某个成员不能拥有同名版本库,不同的成员可以创建同名版本库
def is_sigle_identifier?(user_id, iden)
projects = Project.where("user_id =?",user_id)

View File

@ -53,12 +53,12 @@
<% if @changesets_latest_coimmit %>
<% if !user_commit_rep(@changesets_latest_coimmit.author_email).nil? %>
<%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
<span class="fl"><div class="fb fontGrey3 mr5 fl hidden maxwidth150"><%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %></div>
<span class="fl"><div class="fb fontGrey3 mr5 fl hidden maxwidth150"><%=link_to get_user_by_mail(@changesets_latest_coimmit.author_email).show_name, user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %></div>
<div class="fl">提交于 <%= time_tag(@changesets_latest_coimmit.created_at) %> 前:</div>
<div class="commit_content_dec fl" title="<%= @changesets_latest_coimmit.comments %>"><%= @changesets_latest_coimmit.message %></div>
</span>
<% else %>
<span class="fl"><div class="fb fontGrey3 mr5 fl hidden maxwidth150"><%=@changesets_latest_coimmit.author_email %></div>
<span class="fl"><div class="fb fontGrey3 mr5 fl hidden maxwidth150"><%= @changesets_latest_coimmit.author_email %></div>
<div class="fl">提交于<%= time_tag(@changesets_latest_coimmit.created_at) %></div>
<div class="commit_content_dec fl" title="<%= @changesets_latest_coimmit.comments %>"><%= @changesets_latest_coimmit.message %></div>
</span>
@ -69,7 +69,7 @@
</span>
<span class="fr mr5"><font class="fb ml2 mr2 vl_commit">
<%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %></font> 提交
<%=link_to "#{choise_commit_count(@changesets_all_count, @g_project.commit_count.to_i)} 提交", {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev, :page => 1 ,:commit_count =>"#{@changesets_all_count}"} %></font>
</span>
</div>
<% end %>

View File

@ -220,7 +220,7 @@
.vl_branch {background:url(../images/vlicon/branch_icon.png) 0px -2px no-repeat; padding-left:22px}
.mt1 {margin-top:1px;}
.mt2 {margin-top:2px;}
.commit_content_dec{width: 400px;overflow: hidden; white-space: nowrap;text-overflow: ellipsis;}
.commit_content_dec{width: 500px;overflow: hidden; white-space: nowrap;text-overflow: ellipsis;}
/*提交信息列表*/
.col-md-10 {