Github API调用:按提交者日期过滤

时间:2017-08-31 21:54:26

标签: github-api

我正在使用github api,试图在特定日期找到我的所有提交。

此查询按预期返回我的所有提交:

  

https://api.github.com/search/commits?q=committer-email:foo@bar.com

但是此查询返回相同的列表,包括指定日期范围之外的结果:

  

https://api.github.com/search/commits?q=committer-email:foo@bar.com&committer-date=2017-08-13..2017-08-14

(这些查询需要设置标题:Accept:application / vnd.github.cloak-preview)

为什么committer-date参数不能像它应该的那样工作?

以下是提交搜索的文档:https://developer.github.com/v3/search/#search-commits

1 个答案:

答案 0 :(得分:3)

查询中存在一个小的语法错误。尝试将&更改为+,将=更改为:。进行这些更改后,您的查询将变为 -

curl -H 'Accept: application/vnd.github.cloak-preview' \https://api.github.com/search/commits?q=committer-email:foo@bar.com+committer-date:2017-08-13..2017-08-14

当我在终端上运行它时,我只得到一次提交(参见下面的截断结果)。

Medapas-MacBook-Air:~ medapa$ curl -H 'Accept: application/vnd.github.cloak-preview' \https://api.github.com/search/commits?q=committer-email:foo@bar.com+committer-date:2017-08-13..2017-08-14
{
  "total_count": 1,
  "incomplete_results": false,
  "items": [
    {
      "url": "https://api.github.com/repos/mstricklin/batis00/commits/af9295b930223e394f7f0d742af351ea3ef02351",
      "sha": "af9295b930223e394f7f0d742af351ea3ef02351",
      "html_url": "https://github.com/mstricklin/batis00/commit/af9295b930223e394f7f0d742af351ea3ef02351",
      "comments_url": "https://api.github.com/repos/mstricklin/batis00/commits/af9295b930223e394f7f0d742af351ea3ef02351/comments",
      "commit": {
        "url": "https://api.github.com/repos/mstricklin/batis00/git/commits/af9295b930223e394f7f0d742af351ea3ef02351",
        "author": {
          "date": "2017-08-13T20:10:55.000-05:00",
          "name": "mstricklin",
          "email": "foo@bar.com"
        },
        "committer": {
          "date": "2017-08-13T20:10:55.000-05:00",
          "name": "mstricklin",
          "email": "foo@bar.com"
        },
        "message": "01",
        "tree": {
          "url": "https://api.github.com/repos/mstricklin/batis00/git/trees/e0fe96439a79eb6d84996f351025488bb0e7114d",
          "sha": "e0fe96439a79eb6d84996f351025488bb0e7114d"
        },
        "comment_count": 0
      },
      "author": {
        "login": "invalid-email-address",