summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-mirror-gitlab-ce12
-rwxr-xr-xgit-mirror-gitlab-ee6
2 files changed, 11 insertions, 7 deletions
diff --git a/git-mirror-gitlab-ce b/git-mirror-gitlab-ce
index dc7a4db..40f864a 100755
--- a/git-mirror-gitlab-ce
+++ b/git-mirror-gitlab-ce
@@ -39,6 +39,10 @@ class GitLabCE < GitMirrorBackend
return @connections[key]
end
+ def request(req)
+ return self.connection(req.uri).request(req)
+ end
+
def finish
@connections.each do |k,v|
v.finish()
@@ -69,7 +73,7 @@ class GitLabCE < GitMirrorBackend
unless @cache.has_key?(:info)
req = Net::HTTP::Get.new(@gl.config['apiurl'] + "projects/" + CGI::escape(@project_id))
req.add_field("PRIVATE-TOKEN", @gl.config['apikey'])
- res = @gl.connection(req.uri).request(req)
+ res = @gl.request(req)
case res.code
when "200"
@cache[:info] = JSON::parse(res.body)
@@ -115,7 +119,7 @@ class GitLabCE < GitMirrorBackend
map["import_url"] = mirror
end
req.body = JSON::dump(map)
- res = @gl.connection(req.uri).request(req)
+ res = @gl.request(req)
if res.code != "201"
raise Error.new([res, res.body])
end
@@ -140,7 +144,7 @@ class GitLabCE < GitMirrorBackend
req.add_field("PRIVATE-TOKEN", @gl.config['apikey'])
req.add_field("Content-Type", "application/json")
req.body = JSON::dump(map)
- res = @gl.connection(req.uri).request(req)
+ res = @gl.request(req)
if res.code != "200"
raise Error.new([res, res.body])
end
@@ -152,7 +156,7 @@ class GitLabCE < GitMirrorBackend
def namespace_path2id(path, pageno=1)
req = Net::HTTP::Get.new(@gl.config['apiurl'] + "namespaces?page=#{pageno}&search=#{CGI::escape(path)}")
req.add_field("PRIVATE-TOKEN", @gl.config['apikey'])
- res = @gl.connection(req.uri).request(req)
+ res = @gl.request(req)
if res.code != "200"
raise Error.new([res, res.body])
end
diff --git a/git-mirror-gitlab-ee b/git-mirror-gitlab-ee
index 2ec79f3..60bdb95 100755
--- a/git-mirror-gitlab-ee
+++ b/git-mirror-gitlab-ee
@@ -32,7 +32,7 @@ class GitLabEE < GitLabCE
unless @cache.has_key?(:mirror)
req = Net::HTTP::Get.new(URI(self.info["web_url"]+"/mirror"))
req.add_field("PRIVATE-TOKEN", @gl.config['apikey'])
- res = @gl.connection(req.uri).request(req)
+ res = @gl.request(req)
if res.code != "200"
throw res
end
@@ -68,7 +68,7 @@ class GitLabEE < GitLabCE
"project[import_url]" => url.to_s,
"project[mirror_user_id]" => @gl.user_id,
}
- res = @gl.connection(req.uri).request(req)
+ res = @gl.request(req)
if res.code != "302"
throw res
end
@@ -105,7 +105,7 @@ class GitLabEE < GitLabCE
def user_id
req = Net::HTTP::Get.new(self.config['apiurl'] + 'user')
req.add_field("PRIVATE-TOKEN", self.config['apikey'])
- res = self.connection(req.uri).request(req)
+ res = self.request(req)
if res.code != "200"
raise Error.new([res, res.body])
end