27 lines
558 B
Ruby
27 lines
558 B
Ruby
require 'httpclient'
|
|
require 'json'
|
|
|
|
|
|
class GerritClient
|
|
|
|
def initialize(config)
|
|
@url = config['url']
|
|
@user = config['user']
|
|
@pass = config['pass']
|
|
end
|
|
|
|
def create_new_git_branch(branch_name)
|
|
gerrit = HTTPClient.new
|
|
gerrit.set_auth(@url, @user, @pass)
|
|
gerrit.force_basic_auth = true
|
|
|
|
begin
|
|
gerrit_resp = gerrit.put(@url + branch_name, {:revision => 'cscf_int'})
|
|
gerrit_parsed = JSON.parse(gerrit_resp.body)
|
|
gerrit_parsed['ref'] == 'refs/head/' + branch_name
|
|
rescue
|
|
return false
|
|
end
|
|
end
|
|
end
|