【问题标题】:How to get a list of all forks of a GitHub repo?如何获取 GitHub 存储库的所有分支的列表?
【发布时间】:2015-03-10 01:53:13
【问题描述】:

我想获取 GitHub 存储库的所有分支的列表(例如 https://github.com/eternicode/bootstrap-datepicker),但是我无法使用 octokit.net 找到它。

我还想获得一个重命名的存储库,我不能只搜索存储库的名称。

有什么提示吗?

澄清:这里描述了其余的 api https://developer.github.com/v3/repos/forks/,但是如何使用 octokit.net 做到这一点?

【问题讨论】:

标签: c# .net github-api octokit.net


【解决方案1】:

该功能最近已添加到 octokit.net: 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);
    }

对于其他指定存储库的方式也存在类似的函数。

请随时在此处编辑此用例的完整代码。

【讨论】:

    【解决方案2】:

    线程有点旧,但万一其他人从谷歌那里结束,我认为 Id necro 它。

            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;
        }
    

    【讨论】:

    • 根据名字(GetAllForUser),它不会返回所有的分叉。
    猜你喜欢
    • 1970-01-01
    • 2020-03-16
    • 2014-09-15
    • 2016-02-13
    • 2011-02-10
    • 2019-08-05
    • 1970-01-01
    • 2019-12-26
    • 2013-03-16
    相关资源
    最近更新 更多