diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-28 10:50:10 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-28 10:50:10 +0300 |
commit | c4dbe61a846ddc97f8161e14771a58f406f65c81 (patch) | |
tree | 1339d0bfbc4b911a2ef698153ba01a4daedb12c0 /lib/bitbucket_server | |
parent | 014abc9c07c1389e64ccf336559b488835730a45 (diff) |
First iteration of importing diff notes
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r-- | lib/bitbucket_server/representation/activity.rb | 13 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/comment.rb | 16 |
2 files changed, 17 insertions, 12 deletions
diff --git a/lib/bitbucket_server/representation/activity.rb b/lib/bitbucket_server/representation/activity.rb index aa168aca8af..7c552c7f428 100644 --- a/lib/bitbucket_server/representation/activity.rb +++ b/lib/bitbucket_server/representation/activity.rb @@ -10,7 +10,7 @@ module BitbucketServer end def inline_comment? - comment? && raw['commentAnchor'] + comment? && comment_anchor end def comment @@ -18,9 +18,9 @@ module BitbucketServer @comment ||= if inline_comment? - PullRequestComment.new(raw_comment) + PullRequestComment.new(raw) else - Comment.new(raw_comment) + Comment.new(raw) end end @@ -61,13 +61,14 @@ module BitbucketServer raw.fetch('comment', {}) end + def comment_anchor + raw['commentAnchor'] + end + def author raw_comment.fetch('author', {}) end - # Anchor hash: - # {u'toHash': u'a4c2164330f2549f67c13f36a93884cf66e976be', u'fromHash': u'c5f4288162e2e6218180779c7f6ac1735bb56eab', u'fileType': u'FROM', u'diffType': u'EFFECTIVE', u'lineType': u'CONTEXT', u'path': u'CHANGELOG.md', u'line': 3, u'orphaned': False} - def created_date comment['createdDate'] end diff --git a/lib/bitbucket_server/representation/comment.rb b/lib/bitbucket_server/representation/comment.rb index bd6f9f08e3c..990905ac5a4 100644 --- a/lib/bitbucket_server/representation/comment.rb +++ b/lib/bitbucket_server/representation/comment.rb @@ -22,7 +22,7 @@ module BitbucketServer # } class Comment < Representation::Base def id - raw['id'] + raw_comment['id'] end def author_username @@ -34,7 +34,7 @@ module BitbucketServer end def note - raw['text'] + raw_comment['text'] end def created_at @@ -46,7 +46,7 @@ module BitbucketServer end def comments - workset = [raw['comments']].compact + workset = [raw_comment['comments']].compact all_comments = [] until workset.empty? @@ -64,16 +64,20 @@ module BitbucketServer private + def raw_comment + raw.fetch('comment', {}) + end + def author - raw.fetch('author', {}) + raw_comment.fetch('author', {}) end def created_date - raw['createdDate'] + raw_comment['createdDate'] end def updated_date - raw['updatedDate'] + raw_comment['updatedDate'] end end end |