diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a72444f0a..24850a585 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -364,13 +364,13 @@ class UsersController < ApplicationController def show # 测试代码 - login_gitlab("admin@local.host","19840410") + #login_gitlab("admin@local.host","19840410") #create_project("testproject1") #create_project_for_user("testproject1","2") #create_user("test","just test","123456","test@sina.com") #delete_user("3") - add_user_to_project("1","2",GitlabHelper::GUEST) - delete_user_from_project("1","2") + #add_user_to_project("1","2",GitlabHelper::GUEST) + #delete_user_from_project("1","2") # 测试结束 pre_count = 10 #limit diff --git a/app/helpers/gitlab_helper.rb b/app/helpers/gitlab_helper.rb index 20faf551c..ceaaf6d21 100644 --- a/app/helpers/gitlab_helper.rb +++ b/app/helpers/gitlab_helper.rb @@ -1,6 +1,8 @@ # Gitlab5.3 API操作接口 # Add by nwb # 暂时没支持SSH +# 接口通过HTTP协议与服务器交互,理论上只要能安装gitlab的操作系统本接口都能支持 +# 本机的测试环境是Ubuntu 12.04 module GitlabHelper @@ -8,6 +10,7 @@ module GitlabHelper ROOT_PATH="/home/git/repositories/" PROJECT_PATH_CUT = 40 # gitlab版本库所在服务器 + # 注意REPO_IP_ADDRESS必须以http://开头,暂时只支持HTTP协议,未支持SSH #REPO_IP_ADDRESS = "http://" + Setting.repository_domain REPO_IP_ADDRESS = "http://192.168.137.100" GITLAB_API = "/api/v3" @@ -18,6 +21,8 @@ module GitlabHelper DEVELOPER = 30 MASTER = 40 + # gitlab的登录验证信息 + # add by nwb def self.gitlab_token=(token) Thread.current[:gitlab_token] = token end @@ -211,7 +216,6 @@ module GitlabHelper #request.set_form_data(params) request.body = params.to_json response = http.start { |http| http.request(request) } - puts response.body.inspect return JSON.parse response.body rescue =>err return nil @@ -234,7 +238,6 @@ module GitlabHelper request['User-Agent'] = 'Mozilla/5.0 (Windows NT 5.1; rv:29.0) Gecko/20100101 Firefox/29.0' request['X-ACL-TOKEN'] = 'xxx_token' response = http.start { |http| http.request request } - puts response.body.inspect return JSON.parse response.body rescue =>err return nil