Github API call: filter by committer-date

柔情痞子 提交于 2019-12-23 12:58:28

问题


I'm using the github api, trying to find all my commits on a specific day.

This query, as expected, returns all my commits:

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

But this query returns that same list, including results outside the specified date range:

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

(These queries require a header to be set: Accept: application/vnd.github.cloak-preview)

Why does the committer-date parameter not work like it's supposed to?

Here are the docs for the commit search: https://developer.github.com/v3/search/#search-commits


回答1:


There is a small syntax error in the query. Try changing & to + and = to :. Making these changes your query would become -

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.

When I run this on my terminal, I just get one commit (see the truncated results below).

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",


来源:https://stackoverflow.com/questions/45990626/github-api-call-filter-by-committer-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!