Mike Miller
Mike Miller

Reputation: 3507

Github API call: filter by committer-date

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:[email protected]

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

https://api.github.com/search/commits?q=committer-email:[email protected]&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

Upvotes: 6

Views: 2089

Answers (1)

Poonacha
Poonacha

Reputation: 1316

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:[email protected]+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:[email protected]+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": "[email protected]"
        },
        "committer": {
          "date": "2017-08-13T20:10:55.000-05:00",
          "name": "mstricklin",
          "email": "[email protected]"
        },
        "message": "01",
        "tree": {
          "url": "https://api.github.com/repos/mstricklin/batis00/git/trees/e0fe96439a79eb6d84996f351025488bb0e7114d",
          "sha": "e0fe96439a79eb6d84996f351025488bb0e7114d"
        },
        "comment_count": 0
      },
      "author": {
        "login": "invalid-email-address",

Upvotes: 3

Related Questions