2018-06-25 16:06:10 -04:00
|
|
|
module BitbucketServer
|
|
|
|
module Representation
|
|
|
|
class PullRequest < Representation::Base
|
|
|
|
def author
|
2018-06-26 01:40:11 -04:00
|
|
|
raw.fetch('author', {}).fetch('user', {}).fetch('name')
|
2018-06-25 16:06:10 -04:00
|
|
|
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
|
2018-06-26 01:40:11 -04:00
|
|
|
raw['createdDate']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def updated_at
|
2018-06-26 01:40:11 -04:00
|
|
|
raw['updatedDate']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
raw['title']
|
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_name
|
2018-06-26 01:40:11 -04:00
|
|
|
source_branch['id']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_sha
|
2018-06-26 01:40:11 -04:00
|
|
|
# XXX Not implemented?
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_name
|
2018-06-26 01:40:11 -04:00
|
|
|
target_branch['id']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_sha
|
2018-06-26 01:40:11 -04:00
|
|
|
# XXX Not implemented?
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def source_branch
|
2018-06-26 01:40:11 -04:00
|
|
|
raw['fromRef'] || {}
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch
|
2018-06-26 01:40:11 -04:00
|
|
|
raw['toRef'] || {}
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|