使用python-gitlab库 获取最新的提交分支
client = gitlab.Gitlab('http://xxxxx.com.cn',private_token='xxxxxxxx', timeout=2, api_version='4')
client.auth()
pro="dxxx/dfdfd/dxdd"
print (pro)
#pdb.set_trace()
project = client.projects.get(pro)
#branches=project.branches.list()
#print (branches[-1])
#for z in branches:
# print(z)
# 最新提交的分支号
re=project.commits.list(page=0, per_page=3,as_list=True)[0].refs("branch")
print (re)
网友评论