Reputation: 65143
Most of the documentation is on authorization, and how to retrieve the basic objects the api provides.
What if I want a particular file from the repo?
Like, say me/repo/blob/master/readme.md
I've tried this:
g.git_data.blobs.get("me", "repo", "master/readme.md")
but I get a 404 error.
I'm working with a private repo, and created the object "g" with basic auth (username and password)
this is the gem i'm using: https://github.com/peter-murach/github/
Update, this is how I authed:
g = Github.new :basic_auth => "me:password"
Upvotes: 1
Views: 492
Reputation: 3915
For me it doesn't work for a private repository but to retrieve a file information from a public repository, the code is
g.repos.contents.get 'kulbirsaini', 'gitlist', 'web/Makefile'
g.repos.contents.get 'kulbirsaini', 'gitlist', 'README.md'
It must be something related to private repository. It'd be best to contact Github support.
Summary of how to get a file from a private repository:
g = Github.new(:basic_auth => "username:password")
file = g.repos.contents.get("username", "private_repo_name", "repo_path_to_file_relative_to_branch")
human_readable_data = Base64.decode64(file)
example of repo_path_to_file_relative_to_branch
:
/lib/core.rb
and NOT
/master/lib/core.rb
Upvotes: 2