2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Bitbucket
|
|
|
|
module Representation
|
|
|
|
class PullRequest < Representation::Base
|
|
|
|
def author
|
2019-10-12 21:52:04 +05:30
|
|
|
raw.fetch('author', {}).fetch('nickname', nil)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
raw['description']
|
|
|
|
end
|
|
|
|
|
|
|
|
def iid
|
|
|
|
raw['id']
|
|
|
|
end
|
|
|
|
|
|
|
|
def state
|
2019-12-26 22:10:19 +05:30
|
|
|
case raw['state']
|
|
|
|
when 'MERGED'
|
2017-08-17 22:00:37 +05:30
|
|
|
'merged'
|
2019-12-26 22:10:19 +05:30
|
|
|
when 'DECLINED', 'SUPERSEDED'
|
2017-08-17 22:00:37 +05:30
|
|
|
'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
|