Skip to content
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

Merged
merged 2 commits into from
Apr 9, 2017

Conversation

andrey-skat
Copy link
Contributor

No description provided.

@andrey-skat andrey-skat changed the title Add Bitbucket server pull requests formatter Add Bitbucket Server pull requests formatter Mar 22, 2017
Copy link
Member

@mmozuras mmozuras left a 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 = {})
Copy link
Member

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?

Copy link
Contributor Author

@andrey-skat andrey-skat Mar 23, 2017

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|
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

@andrey-skat andrey-skat Mar 23, 2017

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

def pull_comments(sha)
@comment_cache["#{pull_id}/#{sha}"] ||= begin
client.pull_comments(slug, pull_id).map do |comment|
if comment['commentAnchor']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a commentAnchor?

Copy link
Contributor Author

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)

if comment['commentAnchor']
Comment.new(sha, comment['comment']['text'], comment['commentAnchor']['path'], comment['commentAnchor']['line'])
else
Comment.new(sha, comment['comment']['text'])
Copy link
Member

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?

Copy link
Contributor Author

@andrey-skat andrey-skat Mar 23, 2017

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

Copy link
Contributor Author

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

@andrey-skat
Copy link
Contributor Author

I'll try to add some specs :)

@andrey-skat
Copy link
Contributor Author

I've updated pull request.
Not sure if tests are good 😔

@mmozuras
Copy link
Member

mmozuras commented Apr 9, 2017

@andrey-skat thanks, they're fine! 😄

@mmozuras mmozuras merged commit 96bba3d into prontolabs:master Apr 9, 2017
apiology pushed a commit to apiology/pronto that referenced this pull request Dec 27, 2019
Add Bitbucket Server pull requests formatter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants