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

download repos #50

Open
hienmvvn opened this issue Mar 20, 2016 · 2 comments
Open

download repos #50

hienmvvn opened this issue Mar 20, 2016 · 2 comments

Comments

@hienmvvn
Copy link

how to download repos?
this is my code, but cant download repos

in controller :
`def set_bitbucket(user)
bitbucket = BitBucket.new do |config|
config.oauth_token = user.oauth_token
config.oauth_secret = user.oauth_secret
config.client_id = Settings.BITBUCKET_CLIENT_ID
config.client_secret = Settings.BITBUCKET_CLIENT_SECRET
config.adapter = :net_http
end
end

def index
@repositories = set_bitbucket(current_user).repos
end
**in view :**

<%= link_to "download", @repositories.download.get('dongpp_57', 'demo') %> ` **it's result:** https://bitbucket.org/dongpp_57/demo/get/.tar.gz (**error)**

i read file download.rb in api, but i dont how to get params[:commit_hash] and understand REQUIRED_KEY_PARAM_NAMES.
@vongrippen please help me, thank you.

in download.rb :
`module BitBucket
class Repos::Download < API
REQUIRED_KEY_PARAM_NAMES = %w[ commit_hash ].freeze
def get(user_name, repo_name, params={})
_update_user_repo_params(user_name, repo_name)
_validate_user_repo_params(user, repo) unless user? && repo?

normalize! params

#assert_required_keys(REQUIRED_KEY_PARAM_NAMES, params)

https://bitbucket.org/jhanley85/eternum_canvas_demo/get/fd931f96f12d.zip

"https://bitbucket.org/#{user}/#{repo.downcase}/get/#{params[:commit_hash]}.tar.gz"
end
end # Repos::Keys
end # BitBucket
`

@ghost
Copy link

ghost commented Mar 24, 2016

@hienmv94. This is not actually using the Bitbucket API so it is going to be removed. To implement your feature I would suggest passing

https://bitbucket.org/#{username}/#{repo_name}/get/#{branch_name}.tar.gz 

in the link_to helper.

@hienmvvn
Copy link
Author

@alfredoliverwillder thank you very much.
I try https://bitbucket.org/#{username}/#{repo_name}/get/#{branch_name}.tar.gz and success.
However, in file download.rb in this gem, it's still params[:commit_hash]. so sad..

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

1 participant