2018-10-06 19:10:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-22 15:15:15 -04:00
|
|
|
module Bitbucket
|
|
|
|
module Representation
|
|
|
|
class PullRequest < Representation::Base
|
2016-08-22 15:15:39 -04:00
|
|
|
def author
|
2019-08-07 09:01:18 -04:00
|
|
|
raw.fetch('author', {}).fetch('nickname', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
raw['description']
|
|
|
|
end
|
|
|
|
|
|
|
|
def iid
|
|
|
|
raw['id']
|
|
|
|
end
|
|
|
|
|
|
|
|
def state
|
2019-10-29 11:07:20 -04:00
|
|
|
case raw['state']
|
|
|
|
when 'MERGED'
|
2016-08-22 15:15:39 -04:00
|
|
|
'merged'
|
2019-10-29 11:07:20 -04:00
|
|
|
when 'DECLINED', 'SUPERSEDED'
|
2016-08-22 15:15:39 -04:00
|
|
|
'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
|
2016-12-16 16:51:40 -05:00
|
|
|
source_branch.fetch('branch', {}).fetch('name', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_sha
|
2016-12-16 16:51:40 -05:00
|
|
|
source_branch.fetch('commit', {}).fetch('hash', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_name
|
2016-12-16 16:51:40 -05:00
|
|
|
target_branch.fetch('branch', {}).fetch('name', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_sha
|
2016-12-16 16:51:40 -05:00
|
|
|
target_branch.fetch('commit', {}).fetch('hash', nil)
|
2016-08-22 15:15:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def source_branch
|
|
|
|
raw['source']
|
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch
|
|
|
|
raw['destination']
|
|
|
|
end
|
2016-08-22 15:15:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|