只有在同步项目时才同步用户
This commit is contained in:
parent
be25a57eaf
commit
fa0332babd
|
@ -125,20 +125,8 @@ update
|
|||
@repository.type = 'Repository::Gitlab'
|
||||
@repository.url = @repository.identifier
|
||||
if request.post? && @repository.save
|
||||
g = ::Gitlab.client
|
||||
gid = @project.owner.gid
|
||||
gproject = g.create_project(@repository.identifier,
|
||||
path: @repository.identifier,
|
||||
description: @project.description,
|
||||
wiki_enabled: false,
|
||||
wall_enabled: false,
|
||||
issues_enabled: false,
|
||||
snippets_enabled: false,
|
||||
public: false,
|
||||
user_id: gid
|
||||
)
|
||||
@project.gpid = gproject.id
|
||||
@project.save!
|
||||
s = Trustie::Gitlab::Sync.new
|
||||
s.create_project(@project, @repository)
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories')
|
||||
else
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages)
|
||||
|
|
|
@ -9,8 +9,8 @@ module Trustie
|
|||
|
||||
def self.included(base)
|
||||
base.class_eval {
|
||||
before_create :add_gitlab_user
|
||||
before_destroy :delete_gitlab_user
|
||||
#before_create :add_gitlab_user
|
||||
#before_destroy :delete_gitlab_user
|
||||
before_save :change_gitlab_user
|
||||
}
|
||||
end
|
||||
|
|
|
@ -26,10 +26,37 @@ module Trustie
|
|||
user.mail_notification = "day"
|
||||
end
|
||||
user.save!
|
||||
u
|
||||
end
|
||||
|
||||
|
||||
def create_project(project, repository)
|
||||
gid = project.owner.gid
|
||||
unless gid
|
||||
gid = sync_user(project.owner).id
|
||||
end
|
||||
raise "unknow gid" unless gid
|
||||
|
||||
gproject = g.create_project(repository.identifier,
|
||||
path: repository.identifier,
|
||||
description: project.description,
|
||||
wiki_enabled: false,
|
||||
wall_enabled: false,
|
||||
issues_enabled: false,
|
||||
snippets_enabled: false,
|
||||
public: false,
|
||||
user_id: gid
|
||||
)
|
||||
project.gpid = gproject.id
|
||||
project.save!
|
||||
end
|
||||
|
||||
def sync_project(project, opt={})
|
||||
gid = project.owner.gid
|
||||
unless gid
|
||||
gid = sync_user(project.owner).id
|
||||
end
|
||||
|
||||
raise "unknow gid" unless gid
|
||||
path = opt[:path]
|
||||
raise "unknow path" unless path
|
||||
|
@ -61,7 +88,11 @@ module Trustie
|
|||
|
||||
project.members.each do |m|
|
||||
begin
|
||||
self.g.add_team_member(gproject.id, m.user.gid, UserLevel::DEVELOPER)
|
||||
gid = m.user.gid
|
||||
unless gid
|
||||
gid = sync_user(m.user).id
|
||||
end
|
||||
self.g.add_team_member(gproject.id, gid, UserLevel::DEVELOPER)
|
||||
rescue => e
|
||||
puts e
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue