diff options
author | Stan Hu <stanhu@gmail.com> | 2018-07-03 16:37:17 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-03 16:37:17 -0700 |
commit | d3c75ea4d916e0c81de2e8f7c5b1d748af9fa45e (patch) | |
tree | dd51512d9c007743cb6bf7d01af1c6b6c9e12c2e /lib/bitbucket_server | |
parent | 5f362686ca20f2ff81f5c86a6f9be9b31177c62b (diff) | |
download | gitlab-ce-d3c75ea4d916e0c81de2e8f7c5b1d748af9fa45e.tar.gz |
Support creating a remote branch to import closed pull requests
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r-- | lib/bitbucket_server/client.rb | 10 | ||||
-rw-r--r-- | lib/bitbucket_server/connection.rb | 16 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/bitbucket_server/client.rb b/lib/bitbucket_server/client.rb index e632adea68c..49654e45226 100644 --- a/lib/bitbucket_server/client.rb +++ b/lib/bitbucket_server/client.rb @@ -27,6 +27,16 @@ module BitbucketServer get_collection(path, :repo) end + def create_branch(project_key, repo, branch_name, sha) + payload = { + name: branch_name, + startPoint: sha, + message: 'GitLab temporary branch for import' + } + + connection.post("/projects/#{project_key}/repos/#{repo}/branches", payload.to_json) + end + private def get_collection(path, type) diff --git a/lib/bitbucket_server/connection.rb b/lib/bitbucket_server/connection.rb index 5c3bea3b743..21807c8a229 100644 --- a/lib/bitbucket_server/connection.rb +++ b/lib/bitbucket_server/connection.rb @@ -12,7 +12,6 @@ module BitbucketServer end def get(path, extra_query = {}) - auth = { username: username, password: token } response = Gitlab::HTTP.get(build_url(path), basic_auth: auth, params: extra_query) @@ -20,8 +19,23 @@ module BitbucketServer response.parsed_response end + def post(path, body) + Gitlab::HTTP.post(build_url(path), + basic_auth: auth, + headers: post_headers, + body: body) + end + private + def auth + @auth ||= { username: username, password: token } + end + + def post_headers + @post_headers ||= { 'Content-Type' => 'application/json' } + end + def build_url(path) return path if path.starts_with?(root_url) |