Class: BitbucketServer::Representation::PullRequestComment
- Inherits:
-
Comment
- Object
- Base
- Comment
- BitbucketServer::Representation::PullRequestComment
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 https://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_name, #author_username, #comments, #created_at, #id, #initialize, #note, #updated_at
Methods inherited from Base
convert_timestamp, decorate, #initialize
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
.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
['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_hash ⇒ Object
69
70
71
72
73
74
75
76
77
|
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 69
def to_hash
super.merge(
from_sha: from_sha,
to_sha: to_sha,
file_path: file_path,
old_pos: old_pos,
new_pos: new_pos
)
end
|
#to_sha ⇒ Object
25
26
27
|
# File 'lib/bitbucket_server/representation/pull_request_comment.rb', line 25
def to_sha
['toHash']
end
|