How to retrieve git commit history for specific time period with cURL?

前端 未结 2 412
故里飘歌
故里飘歌 2021-01-29 01:14

I am trying to retrieve commit history as JSON and output in a txt file.

curl https://api.github.com/repos/username/repo/commits > commitHistory.txt


        
相关标签:
2条回答
  • 2021-01-29 01:44

    You can use since and until parameters to get commits only for specific time period:

    curl https://api.github.com/repos/username/repo/commits?since=2016-11-01T00:00:00Z&until=2016-11-01T23:59:59Z
    

    For details: See api doc .

    0 讨论(0)
  • 2021-01-29 01:46

    API requests from GitHub are automatically paginated for large result sets, so you'll need to inspect the Link: header and make further requests while ever there are more results. The API documentation offers more information:

    Requests that return multiple items will be paginated to 30 items by default. You can specify further pages with the ?page parameter. For some resources, you can also set a custom page size up to 100 with the ?per_page parameter. Note that for technical reasons not all endpoints respect the ?per_page parameter, see events for example.

    curl 'https://api.github.com/user/repos?page=2&per_page=100'

    Note that page numbering is 1-based and that omitting the ?page parameter will return the first page.

    For more information on pagination, check out our guide on Traversing with Pagination.

    You could also do this using a Python library like github3.py (or equivalent), which will handle pagination for you.

    In terms of a specific date range, philipjkim's answer is correct: use the since and until parameters.

    0 讨论(0)
提交回复
热议问题