bitbucket-rest-api / bitbucket

BitBucket API gem - bitbucket_rest_api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how do you get commits?

kevinchugh opened this issue · comments

I can instantiate an instance of Bitbucket, I can authenticate, I can get repos, but given an authenticated bitbucket instance, how do you actually retrieve a list of commits? I have tried setting the repo attribute to a repo name (returned from .repos.list) and I've tried setting the repo attribute to a repo object, and have tried bitbucket.repo.commits but always get nil. Can you give me some guidance? Thanks for any help.

Same problem here. Did you manage to fix this?

I'm experiencing this as well. I know it's been some time since there has been any work on tis repo, but I think you have a good thing going here. I'd like to see this working

Maybe a bit late but I would like to share what I found.
Once you have your Oauth credentials set, you can do something like this:
comm = BitBucket::Repos::Commits.new
@commits = comm.get(bitbucket_user_name, bitbucket_repo_name)

Sorry, also you need to get a forked version of the gem (as commits resource is found in 2.0 Bitbucket API version, not 1.0)

I've made a PR for this. If it gets merged you should just be able to run:

BitBucket::Repos::Commits.new.get('username', 'repo_name')

from your app, provided you are authenticated.

@alfredoliverwillder Firstly Thanks for that pull request. I had used
BitBucket::Repos::Commits.new.get('username', 'repo_name') but there is an error saying

BitBucket::Error::NotFound: GET https://bitbucket.org/api/1.0/repositories/atchyut_re/ruby/commits: 404 {"error": {"message": "Resource not found", "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://confluence.atlassian.com/x/IYBGDQ"}}

But the changes in the code are getting the url of version 2.0
get_request("/2.0/repositories/#{user}/#{repo.downcase}/commits")

So, can you please once look at this?