diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-27 14:25:09 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-27 14:25:09 -0700 |
commit | 5728ffbf12c8f5f767bc6d6b9a453b2add974e96 (patch) | |
tree | 5ce0a223a0fa5c3213107f7864d499b104390673 /lib/bitbucket_server | |
parent | 4a6ed4792f107f2180e85001c9e0ebe653e42b14 (diff) | |
download | gitlab-ce-5728ffbf12c8f5f767bc6d6b9a453b2add974e96.tar.gz |
Import standalone pull request comments
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r-- | lib/bitbucket_server/client.rb | 2 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/activity.rb | 84 | ||||
-rw-r--r-- | lib/bitbucket_server/representation/pull_request.rb | 4 |
3 files changed, 89 insertions, 1 deletions
diff --git a/lib/bitbucket_server/client.rb b/lib/bitbucket_server/client.rb index eb8b592e833..c3cb1608187 100644 --- a/lib/bitbucket_server/client.rb +++ b/lib/bitbucket_server/client.rb @@ -24,7 +24,7 @@ module BitbucketServer def activities(project_key, repo, pull_request) path = "/projects/#{project_key}/repos/#{repo}/pull-requests/#{pull_request}/activities" - collection = get_collection(path, :activities) + collection = get_collection(path, :activity) end def pull_request_diff(project_key, repo, pull_request) diff --git a/lib/bitbucket_server/representation/activity.rb b/lib/bitbucket_server/representation/activity.rb new file mode 100644 index 00000000000..207bc848b28 --- /dev/null +++ b/lib/bitbucket_server/representation/activity.rb @@ -0,0 +1,84 @@ +module BitbucketServer + module Representation + class Activity < Representation::Base + def action + raw['action'] + end + + def comment? + action == 'COMMENTED'.freeze + end + + def inline_comment? + comment? && raw['commentAnchor'] + end + + def id + raw['id'] + end + + def note + comment['text'] + end + + def author_username + author['name'] + end + + def author_email + author['emailAddress'] + end + + def merge_event? + action == 'MERGED' + end + + def commiter_user + commit.fetch('committer', {})['displayName'] + end + + def commiter_email + commit.fetch('committer', {})['emailAddress'] + end + + def merge_timestamp + timestamp = commit.fetch('committer', {})['commiterTimestamp'] + + Time.at(timestamp / 1000.0) if timestamp.is_a?(Integer) + end + + def commit + raw.fetch('commit', {}) + end + + def created_at + Time.at(created_date / 1000) if created_date.is_a?(Integer) + end + + def updated_at + Time.at(updated_date / 1000) if created_date.is_a?(Integer) + end + + private + + def comment + raw.fetch('comment', {}) + end + + def author + 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 + + def updated_date + comment['updatedDate'] + end + end + end +end diff --git a/lib/bitbucket_server/representation/pull_request.rb b/lib/bitbucket_server/representation/pull_request.rb index 7c03e9a401a..96a27564641 100644 --- a/lib/bitbucket_server/representation/pull_request.rb +++ b/lib/bitbucket_server/representation/pull_request.rb @@ -5,6 +5,10 @@ module BitbucketServer raw.fetch('author', {}).fetch('user', {}).fetch('name') end + def author_email + raw.fetch('author', {}).fetch('user', {}).fetch('emailAddress') + end + def description raw['description'] end |