-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Bitbucket Server pull requests formatter #216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start, but a couple of changes needed 👍
And could you also add some specs for the new classes? 😄
self.class.post(url, body: body.to_json, headers: @headers) | ||
end | ||
|
||
def paged_request(url, query = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrey-skat what's the reason for doing paged_request
? Should we use it for BitbucketClient
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitbucket Server use paged API for get responses, so we must iterate over many pages.
As far as I know, Bitbucket cloud returns all comments at once.
end | ||
|
||
def paged_request(url, query = {}) | ||
Enumerator.new do |y| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y
is not a great variable name 😄
Could you change it to something more descriptive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a yielder
. I'll rename it
@@ -0,0 +1,64 @@ | |||
class BitbucketServerClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could parts of this class be extracted to reduce duplication between BitbucketServerClient
and BitbucketClient
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see too much duplication between these two 😔 They only have common interface
lib/pronto/bitbucket_server.rb
Outdated
def pull_comments(sha) | ||
@comment_cache["#{pull_id}/#{sha}"] ||= begin | ||
client.pull_comments(slug, pull_id).map do |comment| | ||
if comment['commentAnchor'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's a commentAnchor
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It contains data about comment place (file path, line number, etc)
lib/pronto/bitbucket_server.rb
Outdated
if comment['commentAnchor'] | ||
Comment.new(sha, comment['comment']['text'], comment['commentAnchor']['path'], comment['commentAnchor']['line']) | ||
else | ||
Comment.new(sha, comment['comment']['text']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to access properties via ['comment']['text']
?
What would it take to make it more similar to bitbucket.rb
, accessing it like comment.text
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitbucket Server can return not only inline comments, but comments for file and pull request itself, so we need to handle that comments.
I can rewrite this using local variable or use inject instead of map for exclude that kind of comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also format of returned data is different between bitbucket and bitbucket server
I'll try to add some specs :) |
I've updated pull request. |
@andrey-skat thanks, they're fine! 😄 |
Add Bitbucket Server pull requests formatter
No description provided.