【问题标题】:How to put labels on new pull request using github3.py?如何使用 github3.py 在新的拉取请求上添加标签?
【发布时间】:2021-01-21 07:22:54
【问题描述】:

我看到 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 许可证代码。

【问题讨论】:

    标签: python python-3.x api github github3.py


    【解决方案1】:

    其实这样做的方法是:

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

    感谢 Github 上的 @sigmavirus24。

    【讨论】:

      猜你喜欢
      • 2015-09-28
      • 1970-01-01
      • 2017-08-30
      • 2014-05-06
      • 2017-11-11
      • 2020-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多