Merge branch 'gitlab_guange' of http://repository.trustie.net/xianbo/trustie2 into gitlab_guange

This commit is contained in:
huang 2015-11-27 18:01:28 +08:00
commit aefab8abf3
2 changed files with 52 additions and 29 deletions

View File

@ -1,16 +1,16 @@
<%= form_tag( <%= form_tag(
{:controller => 'repositories', :action => 'diff', :id => project, {:controller => 'repositories', :action => 'diff', :id => project,
:repository_id => @repository.identifier_param, :path => to_path_param(path)}, :repository_id => @repository.identifier_param, :path => to_path_param(path)},
:method => :get :method => :get
) do %> ) do %>
<table class="list changesets"> <table class="list changesets">
<!--<thead><tr>--> <!--<thead><tr>-->
<!--<th>#</th>--> <!--<th>#</th>-->
<!--<th></th>--> <!--<th></th>-->
<!--<th></th>--> <!--<th></th>-->
<!--<th><%= l(:label_date) %></th>--> <!--<th><%= l(:label_date) %></th>-->
<!--<th><%= l(:field_author) %></th>--> <!--<th><%= l(:field_author) %></th>-->
<!--<th><%= l(:field_comments) %></th>--> <!--<th><%= l(:field_comments) %></th>-->
<!--</tr></thead>--> <!--</tr></thead>-->
<tbody> <tbody>
@ -24,6 +24,7 @@
<strong class="str-truncated"> <strong class="str-truncated">
<a class="commit-row-message"><%= textilizable(truncate_at_line_break(changeset.message)) %></a> <a class="commit-row-message"><%= textilizable(truncate_at_line_break(changeset.message)) %></a>
</strong> </strong>
<div class="pull-right" title="修订号"> <div class="pull-right" title="修订号">
<%= h truncate(changeset.short_id.to_s, :length => 20) %> <%= h truncate(changeset.short_id.to_s, :length => 20) %>
</div> </div>
@ -31,13 +32,29 @@
</div> </div>
</div> </div>
<div class="commit-row-info"> <div class="commit-row-info">
<a class="commit-author-link has_tooltip"> <span class="commit-author-name"> <% if !user_commit_rep(changeset.author_email).nil? %>
<%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %> <a class="commit-author-link has_tooltip"> <span class="commit-author-name">
<%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %></span></a> <%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %>
提交于 <%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %></span></a>
<div class="committed_ago"> 提交于
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> 前</time> &nbsp; <div class="committed_ago">
</div> <time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %>
</time>
&nbsp;
</div>
<% else %>
<span class="commit-author-name"><%= changeset.author_email %></span>
提交于
<div class="committed_ago">
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %>
</time>
&nbsp;
</div>
<% end %>
</div> </div>
</li> </li>
</ul> </ul>
@ -50,7 +67,7 @@
</p> </p>
<ul class="wlist"> <ul class="wlist">
<%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true%> <%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true %>
</ul> </ul>
<% end %> <% end %>

View File

@ -6,24 +6,30 @@ namespace :gitlab do
users = User.find_by_sql("select * from users where gid is null") users = User.find_by_sql("select * from users where gid is null")
s = Trustie::Gitlab::Sync.new s = Trustie::Gitlab::Sync.new
g = Gitlab.client g = Gitlab.client
logger = Logger.new('./log/add_gid.log', 'daily') #按天生成
users.each do |user| users.each do |user|
us = g.get("/users?search=#{user.mail}") begin
puts user.mail us = g.get("/users?search=#{user.mail}")
if us.blank? puts user.mail
puts "55555555555555555" if us.blank?
s.sync_user(user) puts "55555555555555555"
else s.sync_user(user)
# 解决查询的时候出现多值的情况,比如:123@163.com和g123@163.com else
puts "66666666666666666666" # 解决查询的时候出现多值的情况,比如:123@163.com和g123@163.com
puts user.id puts "66666666666666666666"
if Array === us puts user.id
us.each do |u| if Array === us
if u.email == user.mail us.each do |u|
user.gid = u.id if u.email == user.mail
user.save user.gid = u.id
user.save
end
end end
end end
end end
rescue => e
logger.error("userid=#{user.id},mail=#{user.mail},login=#{user.login},error=#{e}")
puts e
end end
end end
end end