summaryrefslogtreecommitdiff
path: root/lib/bitbucket
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-11-16 00:13:17 -0800
committerStan Hu <stanhu@gmail.com>2016-11-21 16:47:28 -0800
commitea393e6f308e5dcdd5c48433285594db0539b203 (patch)
tree28056b3682bd21cf08bedb564039291fb975b17a /lib/bitbucket
parent489d241c8d68ed527fccb73a1f7e46e9a567c971 (diff)
downloadgitlab-ce-ea393e6f308e5dcdd5c48433285594db0539b203.tar.gz
Import pull request comments
Diffstat (limited to 'lib/bitbucket')
-rw-r--r--lib/bitbucket/client.rb7
-rw-r--r--lib/bitbucket/representation/pull_request_comment.rb39
2 files changed, 46 insertions, 0 deletions
diff --git a/lib/bitbucket/client.rb b/lib/bitbucket/client.rb
index 0368f388ea4..fce1c898030 100644
--- a/lib/bitbucket/client.rb
+++ b/lib/bitbucket/client.rb
@@ -28,6 +28,13 @@ module Bitbucket
Collection.new(paginator)
end
+ def pull_request_comments(repo, pull_request)
+ relative_path = "/repositories/#{repo}/pullrequests/#{pull_request}/comments"
+ paginator = Paginator.new(connection, relative_path, :pull_request_comment)
+
+ Collection.new(paginator)
+ end
+
def repo(name)
parsed_response = connection.get("/repositories/#{name}")
Representation::Repo.new(parsed_response)
diff --git a/lib/bitbucket/representation/pull_request_comment.rb b/lib/bitbucket/representation/pull_request_comment.rb
new file mode 100644
index 00000000000..94719edbf38
--- /dev/null
+++ b/lib/bitbucket/representation/pull_request_comment.rb
@@ -0,0 +1,39 @@
+module Bitbucket
+ module Representation
+ class PullRequestComment < Comment
+ def iid
+ raw['id']
+ end
+
+ def file_path
+ inline.fetch('path', nil)
+ end
+
+ def old_pos
+ inline.fetch('from', nil) || 1
+ end
+
+ def new_pos
+ inline.fetch('to', nil) || 1
+ end
+
+ def parent_id
+ raw.fetch('parent', {}).fetch('id', nil)
+ end
+
+ def inline?
+ raw.has_key?('inline')
+ end
+
+ def has_parent?
+ raw.has_key?('parent')
+ end
+
+ private
+
+ def inline
+ raw.fetch('inline', {})
+ end
+ end
+ end
+end