Class: BitbucketServer::Representation::PullRequestComment
- 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
Attributes inherited from Base
Instance Method Summary collapse
- #added? ⇒ Boolean
- #file_path ⇒ Object
- #from? ⇒ Boolean
- #from_sha ⇒ Object
-
#new_pos ⇒ Object
There are three line comment types: added, removed, or context.
- #old_pos ⇒ Object
- #removed? ⇒ Boolean
- #to? ⇒ Boolean
- #to_sha ⇒ Object
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
37 38 39 |
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 37 def added? line_type == 'ADDED' end |
#file_path ⇒ Object
65 66 67 |
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 65 def file_path comment_anchor.fetch('path') end |
#from? ⇒ Boolean
33 34 35 |
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 33 def from? file_type == 'FROM' end |
#from_sha ⇒ Object
21 22 23 |
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 21 def from_sha comment_anchor['fromHash'] end |
#new_pos ⇒ Object
There are three line comment types: added, removed, or context.
-
An added type means a new line was inserted, so there is no old position.
-
A removed type means a line was removed, so there is no new position.
-
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_pos ⇒ Object
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
41 42 43 |
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 41 def removed? line_type == 'REMOVED' end |
#to? ⇒ Boolean
29 30 31 |
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 29 def to? file_type == 'TO' end |
#to_sha ⇒ Object
25 26 27 |
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 25 def to_sha comment_anchor['toHash'] end |