如何使用github3.py在新的拉取请求上添加标签?

2024-04-28 07:01:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我看到github3.py在Repository.create_pull()中仍然没有属性标签,就像在Repository.create_issue()中一样。但是ShortPullRequest上创建了属性标签。所以我试着:

created_pr = repo.create_pull(
    title=pr.title,
    body=pr.body,
    head=pr.head,
    base=pr.base,
)
if pr.labels:
    created_pr.labels = pr.labels
    created_pr.update()

问题是,在我检查GitHub之后,PR是在没有标签的情况下创建的。使用此组件是否有任何解决方案

注意:我不能使用pygithub,因为他们使用LGPL许可证,我想制作MIT许可证代码


Tags: pybaselabels属性titlerepositorycreatebody
1条回答
网友
1楼 · 发布于 2024-04-28 07:01:21

实际上,这样做的方法是:

if pr.labels:
    issue = created_pr.issue()
    issue.add_labels(*pr.labels)

感谢Github上的@sigmavirus24

相关问题 更多 >