Get commits for a repository with date filter using gh api

Viewed 202

I am trying to fetch the commits in a given time range using gh api.

In following command, what options I can use to get required commit details?

gh api repos/owner/repoName/commits .....

1 Answers

Since gh api command is only a way to wrap the GitHub API repo/commits call, all you need is add parameters to your GET query.

Minify your JSON date filer parameters:

{
  "since": {
    "date": "yyyy-mm-dd",
    "time": "hh:mm:ss"
  },
  "until": {
    "date": "yyyy-mm-dd",
    "time": "hh:mm:ss"
  }
}

And:

gh api repos/owner/repoName/commits -f '{"since":{"date":"yyyy-mm-dd","time":"hh:mm:ss"},"until":{"date":"yyyy-mm-dd","time":"hh:mm:ss"}}'
Related