2018-07-25 12:22:53 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-27 21:25:09 +00:00
|
|
|
module BitbucketServer
|
|
|
|
module Representation
|
|
|
|
class Activity < Representation::Base
|
|
|
|
def comment?
|
2018-07-25 12:22:53 +00:00
|
|
|
action == 'COMMENTED'
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def inline_comment?
|
2018-07-25 22:38:45 +00:00
|
|
|
!!(comment? && comment_anchor)
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
|
2018-06-28 07:27:04 +00:00
|
|
|
def comment
|
|
|
|
return unless comment?
|
2018-06-27 21:25:09 +00:00
|
|
|
|
2018-06-28 07:27:04 +00:00
|
|
|
@comment ||=
|
|
|
|
if inline_comment?
|
2018-06-28 07:50:10 +00:00
|
|
|
PullRequestComment.new(raw)
|
2018-06-28 07:27:04 +00:00
|
|
|
else
|
2018-06-28 07:50:10 +00:00
|
|
|
Comment.new(raw)
|
2018-06-28 07:27:04 +00:00
|
|
|
end
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
|
2018-07-25 22:38:45 +00:00
|
|
|
# TODO Move this into MergeEvent
|
2018-06-27 21:25:09 +00:00
|
|
|
def merge_event?
|
|
|
|
action == 'MERGED'
|
|
|
|
end
|
|
|
|
|
2018-06-28 07:27:04 +00:00
|
|
|
def committer_user
|
2018-07-31 06:37:54 +00:00
|
|
|
commit.dig('committer', 'displayName')
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
|
2018-06-28 07:27:04 +00:00
|
|
|
def committer_email
|
2018-07-31 06:37:54 +00:00
|
|
|
commit.dig('committer', 'emailAddress')
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def merge_timestamp
|
2018-07-31 06:37:54 +00:00
|
|
|
timestamp = commit['committerTimestamp']
|
2018-06-27 21:25:09 +00:00
|
|
|
|
2018-07-29 04:48:37 +00:00
|
|
|
self.class.convert_timestamp(timestamp)
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
|
2018-07-31 06:37:54 +00:00
|
|
|
def merge_commit
|
|
|
|
commit['id']
|
|
|
|
end
|
|
|
|
|
2018-06-27 21:25:09 +00:00
|
|
|
def created_at
|
2018-07-29 04:48:37 +00:00
|
|
|
self.class.convert_timestamp(created_date)
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-07-31 06:37:54 +00:00
|
|
|
def commit
|
|
|
|
raw.fetch('commit', {})
|
|
|
|
end
|
|
|
|
|
2018-07-25 22:38:45 +00:00
|
|
|
def action
|
|
|
|
raw['action']
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
|
2018-06-28 07:50:10 +00:00
|
|
|
def comment_anchor
|
|
|
|
raw['commentAnchor']
|
|
|
|
end
|
|
|
|
|
2018-06-27 21:25:09 +00:00
|
|
|
def created_date
|
2018-07-26 03:53:25 +00:00
|
|
|
raw['createdDate']
|
2018-06-27 21:25:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|