diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-25 13:06:10 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-25 13:06:10 -0700 |
commit | ebd8e4333a263138abf2113dd315a97352851cbe (patch) | |
tree | 4e4975eab778d490c20c9252785761a1d78fae26 /lib/bitbucket_server/representation/pull_request.rb | |
parent | 2bac2918b2d6f12d94f739f4b6865b9e9221c642 (diff) | |
download | gitlab-ce-ebd8e4333a263138abf2113dd315a97352851cbe.tar.gz |
WIP: Add support for Bitbucket Server imports
Diffstat (limited to 'lib/bitbucket_server/representation/pull_request.rb')
-rw-r--r-- | lib/bitbucket_server/representation/pull_request.rb | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/bitbucket_server/representation/pull_request.rb b/lib/bitbucket_server/representation/pull_request.rb new file mode 100644 index 00000000000..3553f3adbc7 --- /dev/null +++ b/lib/bitbucket_server/representation/pull_request.rb @@ -0,0 +1,65 @@ +module BitbucketServer + module Representation + class PullRequest < Representation::Base + def author + raw.fetch('author', {}).fetch('username', nil) + 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.fetch('branch', {}).fetch('name', nil) + end + + def source_branch_sha + source_branch.fetch('commit', {}).fetch('hash', nil) + end + + def target_branch_name + target_branch.fetch('branch', {}).fetch('name', nil) + end + + def target_branch_sha + target_branch.fetch('commit', {}).fetch('hash', nil) + end + + private + + def source_branch + raw['source'] + end + + def target_branch + raw['destination'] + end + end + end +end |