python-gitlab 统计代码行数

需求:根据时间段,统计各个研发提交的代码行

实现逻辑:调用原生gitlab接口太复杂,引用python-gitlab 获取commit详情,然后进行统计

===============================================

简单代码

import gitlab

client = gitlab.Gitlab('http://xxxxxx:8080/', private_token='ziKtexMN5Zfj37qRGLsW', timeout=5, api_version='4')
client.auth()
project = client.projects.list()
for pro in project:
    print(pro)
    commits = pro.commits.list(since='2019-08-11T00:00:00Z', ref_name='dev')
    for c in commits:
        print(pro.commits.get(c.id))

返回结果:

python-gitlab 统计代码行数_第1张图片

 

python-gitlab api 文档:https://python-gitlab.readthedocs.io/en/stable/gl_objects/commits.html

 

转载于:https://www.cnblogs.com/dannyyao/p/11405432.html

你可能感兴趣的:(python-gitlab 统计代码行数)