gitlab-org--gitlab-foss/lib/bitbucket_server/representation/activity.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.2 KiB
Ruby
Raw Normal View History

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