6

I would like to get a list of all forks of a GitHub repo (e.g. https://github.com/eternicode/bootstrap-datepicker), however I am unable to find out how to do it using octokit.net.

I want also get a renamed repositories, I could not just search a name of a repository.

Any hints?

CLARIFICATION: The rest api is described here https://developer.github.com/v3/repos/forks/, but how to do it with octokit.net?

TN.
  • 18,874
  • 30
  • 99
  • 157
  • @YuvalItzchakov https://github.com/octokit/octokit.net/search?utf8=%E2%9C%93&q=fork but for forks just for Gists (not git repos). Do you know how to do it? – TN. Jan 12 '15 at 12:04

3 Answers3

12

You can achieve that by visiting:

https://api.github.com/repos/<Author>/<Repo>/forks

Make sure to replace Author and Repo with suitable values.

2

The functionality has been added to octokit.net recently: https://github.com/octokit/octokit.net/blob/b07ce6e11a1b286dda0a65ee427bda3b8abcefb8/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs#L31

    /// <summary>
    /// Gets the list of forks defined for a repository
    /// </summary>
    /// <remarks>
    /// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
    /// </remarks>
    /// <param name="owner">The owner of the repository</param>
    /// <param name="name">The name of the repository</param>
    public IObservable<Repository> GetAll(string owner, string name)
    {
        Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
        Ensure.ArgumentNotNullOrEmptyString(name, "name");

        return GetAll(owner, name, ApiOptions.None);
    }

Similar functions exist for other ways to specify repository.

Please feel free to edit in the full code for this use case here.

snugghash
  • 450
  • 3
  • 13
0

Threads a bit old but in case someone else ends up here from google thought Id necro it.

        private static IReadOnlyList<Octokit.Repository> retrieveGitHubRepos()
    {
        Task<IReadOnlyList<Octokit.Repository>> getRepoList = null;
        string appname = System.AppDomain.CurrentDomain.FriendlyName;
        Octokit.GitHubClient client = new Octokit.GitHubClient(new Octokit.ProductHeaderValue(ConnectionDetails.appName));
        client.Credentials = new Octokit.Credentials(ConnectionDetails.username, ConnectionDetails.password);
        Task.Run(() => getRepoList = client.Repository.GetAllForUser(ConnectionDetails.username)).Wait();
        return getRepoList.Result;
    }