summaryrefslogtreecommitdiff
path: root/lib/bitbucket
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-22 16:15:39 -0300
committerStan Hu <stanhu@gmail.com>2016-11-21 16:47:27 -0800
commit704115c726999d6f0467bbf70087db3ae690d3ab (patch)
tree568936c12663b4b19a3391e72c2e1dacbc74d269 /lib/bitbucket
parent64722a15e39436820a0636804179cf8c8957197e (diff)
downloadgitlab-ce-704115c726999d6f0467bbf70087db3ae690d3ab.tar.gz
Import opened pull request from Bitbucket
Diffstat (limited to 'lib/bitbucket')
-rw-r--r--lib/bitbucket/representation/pull_request.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/bitbucket/representation/pull_request.rb b/lib/bitbucket/representation/pull_request.rb
index 7cbad91e9c8..e7b1f99e9a6 100644
--- a/lib/bitbucket/representation/pull_request.rb
+++ b/lib/bitbucket/representation/pull_request.rb
@@ -1,6 +1,65 @@
module Bitbucket
module Representation
class PullRequest < Representation::Base
+ def author
+ raw.fetch('author', {}).fetch('username', 'Anonymous')
+ end
+
+ def description
+ raw['description']
+ end
+
+ def iid
+ raw['id']
+ end
+
+ def state
+ if raw['state'] == 'MERGED'
+ 'merged'
+ elsif raw['state'] == 'DECLINED'
+ 'closed'
+ else
+ 'opened'
+ end
+ end
+
+ def created_at
+ raw['created_on']
+ end
+
+ def updated_at
+ raw['updated_on']
+ end
+
+ def title
+ raw['title']
+ end
+
+ def source_branch_name
+ source_branch.dig('branch', 'name')
+ end
+
+ def source_branch_sha
+ source_branch.dig('commit', 'hash')
+ end
+
+ def target_branch_name
+ target_branch.dig('branch', 'name')
+ end
+
+ def target_branch_sha
+ target_branch.dig('commit', 'hash')
+ end
+
+ private
+
+ def source_branch
+ raw['source']
+ end
+
+ def target_branch
+ raw['destination']
+ end
end
end
end