Gitlab权限修改

更新项目Gitlab同步更新
This commit is contained in:
huang 2015-11-11 16:33:09 +08:00
parent 16c31e254e
commit 3aa73fba35
2 changed files with 26 additions and 0 deletions

View File

@ -607,6 +607,15 @@ class ProjectsController < ApplicationController
@project.organization_id = params[:organization_id]
params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0
params[:project][:hidden_repo] ? @project.hidden_repo = 1 : @project.hidden_repo = 0
# 更新公开私有时同步gitlab公开私有
g = Gitlab.client
gproject = g.project(@project.gpid)
if params[:project][:is_public]
g.edit_project(gproject.id, 20)
else
g.edit_project(gproject.id, 0)
end
# end
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
if params[:project][:is_public] == '0'

View File

@ -72,6 +72,23 @@ class Gitlab::Client
post(url, :body => {:name => name}.merge(options))
end
# Updates a project team member to a specified access level.
# id (required) - The ID of a project
# name (optional) - project name
# path (optional) - repository name for project
# description (optional) - short project description
# default_branch (optional)
# issues_enabled (optional)
# merge_requests_enabled (optional)
# wiki_enabled (optional)
# snippets_enabled (optional)
# public (optional) - if true same as setting visibility_level = 20
# visibility_level (optional)
def edit_project(id, visibility_level)
put("/projects/#{id}", :body => {:visibility_level => visibility_level})
end
# Deletes a project.
#
# @example