How can I get a list of all github `PushEvents` for a user

拟墨画扇 提交于 2021-02-07 03:07:22

问题


I can see all events for a particular user, for example here are mine:

https://api.github.com/users/arasbm/events

But I am only interested in events of a particular type:

"type": "PushEvent",

How can I get this data without having to process the list of all events (which can be slow). I am trying to do this because I want to get a list of all my PRs that have been merged. If you can give me the curl command that would be awesome. I can not find this anywhere in the github api docs.


回答1:


As confirmed in "How do I get notifications for commits to the framework?", you would have to filter the JSON /users/username/events response.

$.each(data.data, function(key, val) {
  if (val.type == "PushEvent") {
    $.each(val.payload.commits, function(key2, val2) {
      list.append('<li id="' + val2.sha + '"><a href="https://github.com/UnionOfRAD/lithium/commit/' + val2.sha + '">' + val2.message + '</a> [' + val.actor.login + ' @ ' + val.created_at + ']</li>');
    });
  }
});

Or:

You can monitor the commit RSS feed (as in "Setting up an Github Commit RSS feed":

https://github.com/user/repo/commits/master.atom
# more general url:
https://github.com/user/repo/commits/branch_name.atom?login=login&token=token

But that would be for one repo of one user though, not for all the user repos.




回答2:


Take a look at this python script: https://github.com/jimzucker/githubutils/blob/master/githubreflog.py

I created it to pull events and make them readable, you can pipe it in to grep 'PushEvent' or you can modify it to throw away events other that PushEvent by modifying this line, to only contain the events you are interested in.

HANDLEDEVENTS=["CreateEvent","DeleteEvent","PushEvent","CommitCommentEvent"]



来源:https://stackoverflow.com/questions/18733424/how-can-i-get-a-list-of-all-github-pushevents-for-a-user

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!