2018-07-25 08:22:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-25 16:06:10 -04:00
|
|
|
module BitbucketServer
|
|
|
|
module Representation
|
|
|
|
class PullRequest < Representation::Base
|
|
|
|
def author
|
2018-07-21 01:30:28 -04:00
|
|
|
raw.dig('author', 'user', 'name')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
2018-06-27 17:25:09 -04:00
|
|
|
def author_email
|
2018-07-21 01:30:28 -04:00
|
|
|
raw.dig('author', 'user', 'emailAddress')
|
2018-06-27 17:25:09 -04:00
|
|
|
end
|
2020-09-14 14:09:48 -04:00
|
|
|
|
|
|
|
def author_username
|
|
|
|
raw.dig('author', 'user', 'username') ||
|
|
|
|
raw.dig('author', 'user', 'slug') ||
|
|
|
|
raw.dig('author', 'user', 'displayName')
|
|
|
|
end
|
2018-06-27 17:25:09 -04:00
|
|
|
|
2018-06-25 16:06:10 -04:00
|
|
|
def description
|
|
|
|
raw['description']
|
|
|
|
end
|
|
|
|
|
|
|
|
def iid
|
|
|
|
raw['id']
|
|
|
|
end
|
|
|
|
|
|
|
|
def state
|
2018-08-02 17:45:54 -04:00
|
|
|
case raw['state']
|
|
|
|
when 'MERGED'
|
2018-06-25 16:06:10 -04:00
|
|
|
'merged'
|
2018-08-02 17:45:54 -04:00
|
|
|
when 'DECLINED'
|
2018-06-25 16:06:10 -04:00
|
|
|
'closed'
|
|
|
|
else
|
|
|
|
'opened'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-01 08:13:15 -04:00
|
|
|
def merged?
|
|
|
|
state == 'merged'
|
|
|
|
end
|
|
|
|
|
2018-06-25 16:06:10 -04:00
|
|
|
def created_at
|
2018-07-29 00:48:37 -04:00
|
|
|
self.class.convert_timestamp(created_date)
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def updated_at
|
2018-07-29 00:48:37 -04:00
|
|
|
self.class.convert_timestamp(updated_date)
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
raw['title']
|
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_name
|
2018-07-26 01:32:10 -04:00
|
|
|
raw.dig('fromRef', 'id')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def source_branch_sha
|
2018-07-26 01:32:10 -04:00
|
|
|
raw.dig('fromRef', 'latestCommit')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_name
|
2018-07-26 01:32:10 -04:00
|
|
|
raw.dig('toRef', 'id')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch_sha
|
2018-07-26 01:32:10 -04:00
|
|
|
raw.dig('toRef', 'latestCommit')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-07-21 01:30:28 -04:00
|
|
|
def created_date
|
|
|
|
raw['createdDate']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
2018-07-21 01:30:28 -04:00
|
|
|
def updated_date
|
|
|
|
raw['updatedDate']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|