2015-10-16 16:57:45 +08:00
|
|
|
require 'trustie/gitlab/sync'
|
|
|
|
|
2015-06-30 22:12:34 +08:00
|
|
|
namespace :gitlab do
|
2015-07-12 15:56:15 +08:00
|
|
|
namespace :sync do
|
|
|
|
desc "sync users to gitlab"
|
|
|
|
task :users => :environment do
|
|
|
|
# User.where(username: 'root').find_each do |user|
|
2015-10-16 16:57:45 +08:00
|
|
|
s = Trustie::Gitlab::Sync.new
|
2015-10-18 13:16:58 +08:00
|
|
|
User.find_each do |user|
|
2015-10-16 16:57:45 +08:00
|
|
|
s.sync_user(user)
|
2015-07-12 15:56:15 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "update user password"
|
|
|
|
task :password => :environment do
|
2015-10-16 16:57:45 +08:00
|
|
|
s = Trustie::Gitlab::Sync.new
|
|
|
|
s.change_password(1,'5188b7a65acf294ee7deceb397b6f9c62214ea50','dcb8d9fffabec60c2d0d1030b679fbbb')
|
2015-07-12 15:56:15 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "sync projects to gitlab"
|
|
|
|
task :projects => :environment do
|
2015-10-16 16:57:45 +08:00
|
|
|
s = Trustie::Gitlab::Sync.new
|
2015-10-18 13:25:10 +08:00
|
|
|
Project.where(id: ENV["PROJECT_ID"]).find_each do |project|
|
2015-10-18 13:50:59 +08:00
|
|
|
s.sync_project(project, path: ENV["REP_NAME"], import_url: project.repository.url)
|
2015-10-16 16:57:45 +08:00
|
|
|
end
|
|
|
|
end
|
2015-07-12 15:56:15 +08:00
|
|
|
|
2015-10-16 16:57:45 +08:00
|
|
|
desc "remove all projects"
|
|
|
|
task :remove_all_projects => :environment do
|
|
|
|
g = Gitlab.client
|
|
|
|
100.times do
|
|
|
|
g.projects(scope: 'all').each do |p|
|
|
|
|
puts p.id
|
|
|
|
begin
|
|
|
|
g.delete_project(p.id)
|
|
|
|
rescue => e
|
|
|
|
puts e
|
2015-07-12 15:56:15 +08:00
|
|
|
end
|
2015-10-16 16:57:45 +08:00
|
|
|
end
|
2015-07-12 15:56:15 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-30 22:12:34 +08:00
|
|
|
end
|
|
|
|
end
|