[英]python script to print the last commit message from specific git branch
from github import Github
import sys
import requests
import subprocess
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# github connection
gc = Github(login_or_token = '3d09afd6df8d92bd', password = None, b
base_url = "https://eos2git.com/api/v3", timeout = 60, verify=False, retry=5)
# enter github repo
repo_gh = gc.get_repo('Devops/emporium')
# get the branches of the given repo
branches = repo_gh.get_branches()
for branch in branches:
if branch.name == "dev/anjali-raghu/DSE-401":
# print the last commit message of a branch
print(branch.commit)
But the print(branch.commit) print the commit SHA ie, Commit(sha="026493bb65bc12c99f66c159eda050471d6757ff") instead of commit message.但是 print(branch.commit) 打印提交 SHA 即 Commit(sha="026493bb65bc12c99f66c159eda050471d6757ff") 而不是提交消息。
Could you please help me to print the last commit message of a specific branch.您能帮我打印特定分支的最后提交消息吗?
As you can read in the documentation for PyGitHub , GitCommit objects contain .message
attribute with the data you need.正如您在 PyGitHub 的文档中所读到的,GitCommit 对象包含带有您需要的数据的
.message
属性。 Commit
objects contain corresponding GitCommit object in .commit
attribute. Commit
对象在.commit
属性中包含相应的 GitCommit object。 Thus you can access the data you need with branch.commit.commit.message
因此,您可以使用
branch.commit.commit.message
访问所需的数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.