diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-25 22:40:11 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-25 22:40:11 -0700 |
commit | 046a5e398d202be5865a850cf778fedd9bd39c47 (patch) | |
tree | d2d6115e327c3da5ace7b2456480f04386a69f59 /lib/bitbucket_server | |
parent | c9deb7cef8d0d85a8773b0e6d26ae12a3ff25a0e (diff) | |
download | gitlab-ce-046a5e398d202be5865a850cf778fedd9bd39c47.tar.gz |
More work towards supporting Bitbucket Server
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r-- | lib/bitbucket_server/client.rb | 4 | ||||
-rw-r--r-- | lib/bitbucket_server/connection.rb | 2 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/issue.rb | 53 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/pull_request.rb | 18 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/repo.rb | 12 |
5 files changed, 14 insertions, 75 deletions
diff --git a/lib/bitbucket_server/client.rb b/lib/bitbucket_server/client.rb index 1f2f03790dd..27117fa0dcd 100644 --- a/lib/bitbucket_server/client.rb +++ b/lib/bitbucket_server/client.rb @@ -16,8 +16,8 @@ module BitbucketServer get_collection(path, :comment) end - def pull_requests(repo) - path = "/repositories/#{repo}/pullrequests?state=ALL" + def pull_requests(project_key, repository_slug) + path = "/projects/#{project}/repos/#{repo}/pull-requests?state=ALL" get_collection(path, :pull_request) end diff --git a/lib/bitbucket_server/connection.rb b/lib/bitbucket_server/connection.rb index 64f12527a8d..7374b73fa60 100644 --- a/lib/bitbucket_server/connection.rb +++ b/lib/bitbucket_server/connection.rb @@ -8,7 +8,7 @@ module BitbucketServer @api_version = options.fetch(:api_version, DEFAULT_API_VERSION) @base_uri = options[:base_uri] @username = options[:username] - @token = options[:personal_access_token] + @token = options[:password] end def get(path, extra_query = {}) diff --git a/lib/bitbucket_server/representation/issue.rb b/lib/bitbucket_server/representation/issue.rb deleted file mode 100644 index 44bcbc250b3..00000000000 --- a/lib/bitbucket_server/representation/issue.rb +++ /dev/null @@ -1,53 +0,0 @@ -module Bitbucket - module Representation - class Issue < Representation::Base - CLOSED_STATUS = %w(resolved invalid duplicate wontfix closed).freeze - - def iid - raw['id'] - end - - def kind - raw['kind'] - end - - def author - raw.dig('reporter', 'username') - end - - def description - raw.fetch('content', {}).fetch('raw', nil) - end - - def state - closed? ? 'closed' : 'opened' - end - - def title - raw['title'] - end - - def milestone - raw['milestone']['name'] if raw['milestone'].present? - end - - def created_at - raw['created_on'] - end - - def updated_at - raw['edited_on'] - end - - def to_s - iid - end - - private - - def closed? - CLOSED_STATUS.include?(raw['state']) - end - end - end -end diff --git a/lib/bitbucket_server/representation/pull_request.rb b/lib/bitbucket_server/representation/pull_request.rb index 3553f3adbc7..6e248802a07 100644 --- a/lib/bitbucket_server/representation/pull_request.rb +++ b/lib/bitbucket_server/representation/pull_request.rb @@ -2,7 +2,7 @@ module BitbucketServer module Representation class PullRequest < Representation::Base def author - raw.fetch('author', {}).fetch('username', nil) + raw.fetch('author', {}).fetch('user', {}).fetch('name') end def description @@ -24,11 +24,11 @@ module BitbucketServer end def created_at - raw['created_on'] + raw['createdDate'] end def updated_at - raw['updated_on'] + raw['updatedDate'] end def title @@ -36,29 +36,29 @@ module BitbucketServer end def source_branch_name - source_branch.fetch('branch', {}).fetch('name', nil) + source_branch['id'] end def source_branch_sha - source_branch.fetch('commit', {}).fetch('hash', nil) + # XXX Not implemented? end def target_branch_name - target_branch.fetch('branch', {}).fetch('name', nil) + target_branch['id'] end def target_branch_sha - target_branch.fetch('commit', {}).fetch('hash', nil) + # XXX Not implemented? end private def source_branch - raw['source'] + raw['fromRef'] || {} end def target_branch - raw['destination'] + raw['toRef'] || {} end end end diff --git a/lib/bitbucket_server/representation/repo.rb b/lib/bitbucket_server/representation/repo.rb index f4bdb277d28..38778645966 100644 --- a/lib/bitbucket_server/representation/repo.rb +++ b/lib/bitbucket_server/representation/repo.rb @@ -15,16 +15,8 @@ module BitbucketServer raw['slug'] end - def clone_url(token = nil) - url = raw['links']['clone'].find { |link| link['name'].starts_with?('http') }.fetch('href') - - if token.present? - clone_url = URI.parse(url) - clone_url.user = "x-token-auth:#{token}" - clone_url.to_s - else - url - end + def clone_url + raw['links']['clone'].find { |link| link['name'].starts_with?('http') }.fetch('href') end def description |