get_git_month_log.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:minitools 作者: tiberiuichim 项目源码 文件源码
def main():

    parser = ArgumentParser(description="Retrieve Github activity")
    parser.add_argument('month', type=int, help='Month for activity log')
    args = parser.parse_args()
    g = Github(GITHUB_USERNAME, GITHUB_PASS)
    usr = g.get_user(GITHUB_USERNAME)

    year = datetime.now().year
    this = (year, int(args.month))
    tpl = "{0} - {1}: {2}"

    for event in usr.get_public_events():
        # go back in history until the start date is reached
        if event.type != u"PushEvent":
            continue

        if month(event.created_at.date()) > this:
            continue
        # if month(event.created_at.date()) < this:
        #     break

        repo_url = event._repo.value.html_url
        if not is_work_repo(repo_url):
            continue
        repo = repo_url.split('/')[-1]
        commits = event.payload['commits']
        for commit in commits:
            if GITHUB_AUTHOR not in commit['author']['name'].lower():
                continue

            print(tpl.format(event.created_at.date(),
                             repo,
                             commit['message']))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号