【问题标题】:Github repository statistics: Historical data on total contributors for each month for the past x months/years?Github 存储库统计:历史数据?
【发布时间】:2021-09-19 22:48:56
【问题描述】:

假设我们有以下 GitHub 存储库:https://github.com/pytorch/pytorch

在页面右侧,您可以看到Used byContributors 计数。是否有可能每月获取该信息,例如过去 x 个月/年?

在这里使用回程机器似乎并不完美,也是因为数据不完整,因此我想知道是否有(免费)API 可以为您提供历史数据。

提前谢谢你!

【问题讨论】:

    标签: database api github historical-db


    【解决方案1】:

    您需要逐月致电third-party tool,以获得此类活动日志。

    例如:git-stats -s '1 June 2021' -u '30 June 2021'

    或者:askgitdev/askgit 可以针对给定的作者/月份再次查询您的 Git 存储库。

    【讨论】:

      【解决方案2】:

      是的,可以获取有关提交的统计信息。有两种方法可以做到这一点。

      命令行方法

      要从命令行获取有关最近一个月提交的信息,您可以使用以下命令

      git shortlog --since=2021-01-06 --until=2021-01-07 -sn
      

      这里的--since 和--until 是自我解释,而-s 是总结,-n 是编号。

      在 pytorch 上,输出如下。我已将回复删减为仅保留 5 位顶级作者。

      请注意,您需要在本地设置上克隆存储库。

      GitHub API 方法

      curl --location --request GET 'https://api.github.com/repos/pytorch/pytorch/commits?since=2021-01-06&until=2021-01-07' \
      --header 'Accept: application/vnd.github.v3+json'
      

      您可以找到有关 API here 的完整文档。

      没有直接的 API 可以作为命令行获取过去一个月内提交的作者数量。

      需要处理上述 API 的响应以获取计数。而您也可以通过以下API添加作者参数以获取上个月的提交历史记录和有效提交计数。

      curl --location --request GET 'https://api.github.com/repos/pytorch/pytorch/commits?since=2021-01-06&until=2021-01-07&author=myemail@email.com' \
      --header 'Accept: application/vnd.github.v3+json'
      

      请注意标题Accept: application/vnd.github.v3+json 是推荐的,不是强制性的。

      取决于您的具体用例。我们可以使用文档中正确的 API。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-04-06
        • 2012-02-10
        • 1970-01-01
        • 2011-08-09
        • 1970-01-01
        • 2011-04-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多