Home > Net >  Trying to obtain all commits in a specific branch since a certain date or commit id via github api
Trying to obtain all commits in a specific branch since a certain date or commit id via github api

Time:10-24

I need to retrieve all of the commits on a specific branch on a periodic basis from the api. I'd like to do it from the most recent commit that is recorded but since a certain date would work as well.

What I have is

curl https://github.mycompany.com/api/v3/repos/&owner/&repo/commits?sha=branchname

Which seems to get me the correct commits but I'm curious why I can't append &since=datetime for example

curl https://github.mycompany.com/api/v3/repos/&owner/&repo/commits?sha=branchname&since=2021-10-19T00:00:00Z

I have a feeling I'm missing some simple syntax but any help would be appreciated.

CodePudding user response:

You need to put quotes around the URL when you invoke curl from the shell. That's because the shell considers & to be special (it causes the process to be run in the background), so quoting is required in order for the ampersand to be treated as part of the URL.

For example:

$ curl 'https://github.mycompany.com/api/v3/repos/git/git/commits?sha=branchname&since=2021-10-19T00:00:00Z'
  • Related