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

Use the 2.0 version of the Bitbucket API for repository lists #72

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use the 2.0 version of the Bitbucket API for repository lists - this …
…gives us the extra

parameter of role, allowing us to filter the repository list by whether a user is an owner, contributor etc
  • Loading branch information
twoism-dev committed Jul 7, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 40e185b0879f1fa52d5b10ea78838993a3d47211
17 changes: 8 additions & 9 deletions lib/bitbucket_rest_api/repos.rb
Original file line number Diff line number Diff line change
@@ -219,20 +219,19 @@ def delete(user_name, repo_name)
#
# = Examples
# bitbucket = BitBucket.new
# bitbucket.repos.list :user => 'user-name'
# bitbucket.repos.list :user => 'user-name', :role => 'owner'
# bitbucket.repos.list :user => 'user-name', { |repo| ... }
def list(*args)
params = args.extract_options!
normalize! params
_merge_user_into_params!(params) unless params.has_key?('user')
filter! %w[ user type ], params

response = #if (user_name = params.delete("user"))
# get_request("/1.0/users/#{user_name}", params)
#else
# For authenticated user
get_request("/1.0/user/repositories", params)
#end
params.merge!('pagelen' => 100) unless params.has_key?('pagelen')

filter! %w[ user role pagelen ], params

response = get_request("/2.0/repositories", params)

response = response[:values]
return response unless block_given?
response.each { |el| yield el }
end
6 changes: 3 additions & 3 deletions spec/bitbucket_rest_api/repos_spec.rb
Original file line number Diff line number Diff line change
@@ -100,10 +100,10 @@
before do
expect(repo).to receive(:request).with(
:get,
'/1.0/user/repositories',
{},
'/2.0/repositories',
{"pagelen" => 100},
{}
).and_return(['repo1', 'repo2' ,'repo3'])
).and_return(values: ['repo1', 'repo2' ,'repo3'])
end

# FIXME: this method belongs in the User class!