have the following code:
from github import Github
...
g = github(token)
query = f'org:{org_name} author:{username} since=2021-10-19T00:00:00Z'
commits = g.search_commits(query, sort='author-date', order='desc')
If I have the "since" parameter there - I get 0 results. If I take it out, I get hundreds - and that's the problem. I'm doing some processing which can work this way so want to be incremental - ie cache the results and when I call it a few days later - only find the new commits since the last time I read.
From the documentation, this should work - but ... it doesn't - what am I doing wrong.
Short answer: Try to use:
committer-date:<2023-01-01T01:00:00Z
with>, >=, <, <=
Long answer: Basically, pygithub is forwarding the request to REST as mentioned in this link https://pygithub.readthedocs.io/en/stable/github.html?highlight=search_commits#github.MainClass.Github.search_commits
There is a
committer-date
you can use, such likecommitter-date:<2023-01-01T01:00:00Z
. For the correct syntax, you can refer to https://docs.github.com/en/search-github/searching-on-github/searching-commits#search-by-authored-or-committed-dateand more generic syntax here: https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates
You can also test your search syntax here