同步登录
This commit is contained in:
parent
38b97aa558
commit
797ed5081d
1
Gemfile
1
Gemfile
|
@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
|
|||
gem 'iconv'
|
||||
end
|
||||
|
||||
gem 'gitlab'
|
||||
gem 'rest-client'
|
||||
gem "mysql2", "= 0.3.18"
|
||||
gem 'redis-rails'
|
||||
|
|
|
@ -250,6 +250,14 @@ update
|
|||
return -1
|
||||
end
|
||||
end
|
||||
|
||||
if params[:to] == 'gitlab'
|
||||
g = Gitlab.client
|
||||
g.post('/session', body: {email: User.current.mail, password: User.current.hashed_password})
|
||||
redirect_to "http://192.168.41.130:3000/gitlab-org/gitlab-shell/tree/master"
|
||||
return
|
||||
end
|
||||
|
||||
#if( !User.current.member_of?(@project) || @project.hidden_repo)
|
||||
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
|
||||
<% if visible_repository?(@project) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
||||
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id, to: 'gitlab'}, :class => "f14 c_blue02" %>
|
||||
<a class="subnav_num">(<%= @project.repositories.count %>)</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
Gitlab.configure do |config|
|
||||
config.endpoint = 'http://192.168.41.130:3000/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
|
||||
config.private_token = 'cK15gUDwvt8EEkzwQ_63' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
|
||||
# Optional
|
||||
# config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]'
|
||||
# config.sudo = 'user' # username for sudo mode, default: nil
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
namespace :gitlab do
|
||||
desc "sync users to gitlab"
|
||||
task :sync => :environment do
|
||||
User.where(login: 'guange').find_each do |user|
|
||||
g = Gitlab.client
|
||||
unless g.get("/users?search=#{user.mail}")
|
||||
g.create_user(user.mail, user.hashed_password, name: user.show_name, username: user.login)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue