I want to get all informations about files from my github repository using octokit
projectis: http://octokitnet.readthedocs.org/en/latest/contributing/
Updated: what I thought I can do is getAllFilesFromRepository
that will return json with something like example below for all files in repository
{
"type": "symlink",
"target": "/path/to/symlink/target",
"size": 23,
"name": "some-symlink",
"path": "bin/some-symlink",
"sha": "452a98979c88e093d682cab404a3ec82babebb48",
"url": "https://api.github.com/repos/octokit/octokit.rb/contents/bin/some-symlink",
"git_url": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/452a98979c88e093d682cab404a3ec82babebb48",
"html_url": "https://github.com/octokit/octokit.rb/blob/master/bin/some-symlink",
"download_url": "https://raw.githubusercontent.com/octokit/octokit.rb/master/bin/some-symlink",
"_links": {
"git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/452a98979c88e093d682cab404a3ec82babebb48",
"self": "https://api.github.com/repos/octokit/octokit.rb/contents/bin/some-symlink",
"html": "https://github.com/octokit/octokit.rb/blob/master/bin/some-symlink"
}
}
Please note I do not want to download any files at all or write query with multiple calls to retrieve the data.
The easiest way to get started with Octokit is to use a plain GitHubClient: This will let you access unauthenticated GitHub APIs, but you will be subject to rate limiting (you can read more about this here ).
get the sha checksum for the target branch you want to merge into using octokit.gitdata.getReference ( {owner, repo, ref}). If you want to merge into the master branch, the ref parameter will be "heads/master". Then create a branch with [ octokit.gitdata.createReference ] ( {owner, repo, ref, sha}) passing in the sha value from the step above.
When authenticated, you have 5000 requests per hour available. So this is the recommended approach for interacting with the API. Octokit also supports connecting to GitHub Enterprise environments - just provide the URL to your GitHub Enterprise server when creating the client.
In fact, there are two ways to get the Rate Limits via OctoKit.NET. Calling GitHubClient.GetLastApiInfo () returns the Rate Limit status which has been returned with the last api call.
I'm not sure I understand the question, but please read the Getting Started guide first around the setup you need.
This is an example of how to download the contents of a given repository:
var github = new GitHubClient(...); // TODO: other setup
var contents = await github
.Repository
.Content
.GetAllContents("octokit", "octokit.net");
...
var docs = await github
.Repository
.Content
.GetAllContents("octokit", "octokit.net", "docs");
Change the values to suit the repository you're interested in. If you want to download a non-default branch, use GetAllContentsByRef
instead.
GetAllContents method would work fine but one small issue is that it would not iterate recursively through all the sub-folders in your repository. It gives only the files and folders present in the top-level. If you want to list out all the files of your repository, I would suggest you to use the GetRecursive method as follows:
var trees = _gitHubClient.Git.Tree.GetRecursive(_config.Owner, _config.RepositoryId, <<APPROPRIATE SHA>>).Result;
You can get the SHA for the latest commit or as per your requirement.This method would give you a tree response which has sufficient details such as the SHA, Path, Type and Size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With