2013-04-10 45 views
13

我想找到提交到特定github项目的提交数量,并在其中指定特定的文件。我检查了github api docs,但只发现了一个实际返回所有提交的API。这将是非常低效的,因为我必须通过所有提交进行多个API调用来进行寻呼。github api:如何高效地找到存储库的提交数量?

任何人有更好的主意吗?

+0

看到我更新的答案。 – VonC 2013-05-07 06:41:59

+0

@drorw您好,请问您如何整合访问令牌? – user6456773 2016-09-14 14:51:51

回答

9

更新2013年5月:详见 “File CRUD and repository statistics now available in the API

现在,您可以Get the last year of commit activity data

GET /repos/:owner/:repo/stats/commit_activity 

返回星期分组提交活动的最后一年。 days数组是每天的一组提交,从星期天开始。

不是完全你在找什么,但更接近。


原来的答复(2010年4月)

号,当前API不支持 'log --all' 从所有分支列出所有commmits。

唯一的替代方案是在“Github API: Retrieve all commits for all branches for a repo”中出现,并且通过所有提交的所有页面列出,分支后分支

这看起来比另一个替代方案实际上要笨得多克隆 Github回购和apply git commands on that local clone
(主要是git shortlog

+0

感谢您的回答,希望API有待改进 – drorw 2013-04-10 08:21:21

+2

@drorw如果您有关于API的具体建议或功能请求,您应该通过电子邮件发送GitHub支持并让他们知道:https://github.com/contact – 2013-04-10 09:40:21

+0

感谢您的更新,绝对接近 – drorw 2013-05-07 08:40:39

1

随着GraphQL API v4,你可以得到每个分支的总提交计数与totalCount每个分支:

{ 
    repository(owner: "google", name: "gson") { 
    name 
    refs(first: 100, refPrefix: "refs/heads/") { 
     edges { 
     node { 
      name 
      target { 
      ... on Commit { 
       id 
       history(first: 0) { 
       totalCount 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 

Test it in the explorer

相关问题