问题
I am creating an API which runs reports on repos that my company hosts on GitHub. One of the requirements is to list when reports were made private from public. I am not sure if the API has this feature.
Firstly and foremost, I was not able to find this information even manually when I went into GitHub. So from Settings or some other section, is there a way I can see when a repo (of which I am a member) was made private?
回答1:
GitHub doesn't provide information when the visibility of a repo changed.
Their API only shows whether a repo is private or not and the same applies to their regular website. Changes are good that they don't even track when the state changed.
However, the audit log in an organization keeps track of access changes. Unfortunately it is not available in their API (yet?), but you can export it as JSON or CSV on the website, so you could probably pretend to be a user and get the log's JSON and then process it in your script.
Update: I just checked and the exported versions of the audit log are identical when the repo is made public and private; only the human-friendly text version (not part of the export) mention it. So you'd need to check the current state of the repo to know whether the repo.access entry in the audit was public-to-private or private-to-public.
来源:https://stackoverflow.com/questions/41267307/github-api-find-when-repo-made-private