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

Please add support for Bitbucket Teams #128

Closed
npadgen opened this issue Jun 26, 2017 · 8 comments
Closed

Please add support for Bitbucket Teams #128

npadgen opened this issue Jun 26, 2017 · 8 comments

Comments

@npadgen
Copy link

npadgen commented Jun 26, 2017

Please add support for Bitbucket Teams (https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams).

Our Bitbucket instance has lots of repos which we organise by Team. I would like to iterate through each project's repos for reports, e.g. number of open pull requests per team.

To do this I'd like to be able to:

  • list the teams;
  • find the repos belonging to each team.
@hirakiuc
Copy link
Owner

Please add support for Bitbucket Teams

Oh, I think that I forgot to implement part of teams API. 🙇

I try to implement the rest of teams API in next weekend. 💪

This was referenced Jul 4, 2017
@hirakiuc
Copy link
Owner

hirakiuc commented Jul 15, 2017

I released version 1.5.0 😃

This version includes the features what you want.

bucket = Tinybucket.new

bucket.teams(role).each do |team|
  team.repos.each do |repo|
    # Do something with Tinybucket::Model::Repository
    puts repo.name
  end
end

And also you can iterate repositories by projects, like this. ✨

bucket = Tinybucket.new

bucket.teams(role).each do |team|
  team.projects.each do |project|
    project.repos.each do |repo|
      # Do something with Tinybucket::Model::Repository
      puts repo.name
    end
  end
end

Check the bitbucket document about role.

Please enjoy version 1.5.0. 👍

@npadgen
Copy link
Author

npadgen commented Jul 17, 2017

Looks very good, but now I'm getting a problem iterating through repos.

  b.teams('admin').each do |team|
    team.projects.each do |project|
      next unless project.name == 'DevOps'
      project.repos.each do |repo|
        puts repo
      end
    end
  end

gives:

#<Tinybucket::Model::Repository:0x007fe051a9eb68>
#<Tinybucket::Model::Repository:0x007fe051a97bd8>
#<Tinybucket::Model::Repository:0x007fe051a8f208>
#<Tinybucket::Model::Repository:0x007fe051a8dc78>
#<Tinybucket::Model::Repository:0x007fe051a8c328>
#<Tinybucket::Model::Repository:0x007fe05320e848>
#<Tinybucket::Model::Repository:0x007fe053207408>
#<Tinybucket::Model::Repository:0x007fe0532044d8>
#<Tinybucket::Model::Repository:0x007fe0531fd1b0>
#<Tinybucket::Model::Repository:0x007fe05316a540>
ArgumentError: odd number of arguments for Hash
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/iterator.rb:72:in `[]'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/iterator.rb:72:in `next_params'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/iterator.rb:60:in `load_next'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/iterator.rb:46:in `next_value'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/iterator.rb:25:in `next'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/enumerator.rb:19:in `block (2 levels) in initialize'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/enumerator.rb:18:in `loop'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/enumerator.rb:18:in `block in initialize'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/resource/base.rb:14:in `each'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/resource/base.rb:14:in `each'
	from /Users/neilp/lib/gems/gems/tinybucket-1.5.0/lib/tinybucket/resource/base.rb:14:in `method_missing'
	from (irb):301
	from /usr/local/bin/irb:11:in `<main>'

There should be 71 repos listed for this project.

@hirakiuc
Copy link
Owner

Oh, Sorry about that. 🙇

I'll investigate.

@npadgen
Copy link
Author

npadgen commented Jul 17, 2017

Seems to happen for every project with more than 10 repos. It throws the ArgumentError after the tenth repo.

@hirakiuc
Copy link
Owner

Thank you for your report 😃

Yes, it looks like a bug on iterating any resource with the specific query params.
I'll fix that soon. 👍

@hirakiuc
Copy link
Owner

Please try with v1.5.1 which includes the bug fix about your problem. 😃

@npadgen
Copy link
Author

npadgen commented Jul 18, 2017

It works perfectly! Thank you so much for this.

@hirakiuc hirakiuc closed this as completed Aug 9, 2017
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

No branches or pull requests

2 participants