Class: BitbucketServer::Representation::PullRequestComment

Inherits:
Comment
  • Object
show all
Defined in:
lib/bitbucket_server/representation/pull_request_comment.rb

Overview

An inline comment with the following structure that identifies the part of the diff:

“commentAnchor”: {

 "diffType": "EFFECTIVE",
 "fileType": "TO",
 "fromHash": "c5f4288162e2e6218180779c7f6ac1735bb56eab",
 "line": 1,
 "lineType": "ADDED",
 "orphaned": false,
 "path": "CHANGELOG.md",
 "toHash": "a4c2164330f2549f67c13f36a93884cf66e976be"
}

More details in docs.atlassian.com/bitbucket-server/rest/5.12.0/bitbucket-rest.html.

Instance Attribute Summary

Attributes inherited from Comment

#parent_comment

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from Comment

#author_email, #author_username, #comments, #created_at, #id, #initialize, #note, #updated_at

Methods inherited from Base

convert_timestamp, decorate, #initialize

Constructor Details

This class inherits a constructor from BitbucketServer::Representation::Comment

Instance Method Details

#added?Boolean

Returns:

  • (Boolean)

37
38
39
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 37

def added?
  line_type == 'ADDED'
end

#file_pathObject


65
66
67
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 65

def file_path
  comment_anchor.fetch('path')
end

#from?Boolean

Returns:

  • (Boolean)

33
34
35
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 33

def from?
  file_type == 'FROM'
end

#from_shaObject


21
22
23
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 21

def from_sha
  comment_anchor['fromHash']
end

#new_posObject

There are three line comment types: added, removed, or context.

  1. An added type means a new line was inserted, so there is no old position.

  2. A removed type means a line was removed, so there is no new position.

  3. A context type means the line was unmodified, so there is both a old and new position.


51
52
53
54
55
56
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 51

def new_pos
  return if removed?
  return unless line_position

  line_position[1]
end

#old_posObject


58
59
60
61
62
63
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 58

def old_pos
  return if added?
  return unless line_position

  line_position[0]
end

#removed?Boolean

Returns:

  • (Boolean)

41
42
43
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 41

def removed?
  line_type == 'REMOVED'
end

#to?Boolean

Returns:

  • (Boolean)

29
30
31
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 29

def to?
  file_type == 'TO'
end

#to_shaObject


25
26
27
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 25

def to_sha
  comment_anchor['toHash']
end