mirror of
https://github.com/openSUSE/osc.git
synced 2025-11-24 05:48:53 +01:00
Support setting labels in gitea_api.PullRequest.create()
This commit is contained in:
@@ -345,6 +345,7 @@ class PullRequest(GiteaModel):
|
|||||||
source_branch: str,
|
source_branch: str,
|
||||||
title: str,
|
title: str,
|
||||||
description: Optional[str] = None,
|
description: Optional[str] = None,
|
||||||
|
labels: Optional[List[str]] = None,
|
||||||
) -> "PullRequest":
|
) -> "PullRequest":
|
||||||
"""
|
"""
|
||||||
Create a pull request to ``owner``/``repo`` to the ``base`` branch.
|
Create a pull request to ``owner``/``repo`` to the ``base`` branch.
|
||||||
@@ -358,13 +359,18 @@ class PullRequest(GiteaModel):
|
|||||||
:param source_branch: Name of the source branch in the source (forked) repo.
|
:param source_branch: Name of the source branch in the source (forked) repo.
|
||||||
:param title: Pull request title.
|
:param title: Pull request title.
|
||||||
:param description: Pull request description.
|
:param description: Pull request description.
|
||||||
|
:param labels: List of labels to be associated with the pull request.
|
||||||
"""
|
"""
|
||||||
url = conn.makeurl("repos", target_owner, target_repo, "pulls")
|
url = conn.makeurl("repos", target_owner, target_repo, "pulls")
|
||||||
|
if labels:
|
||||||
|
ids = cls._get_label_ids(conn, target_owner, target_repo)
|
||||||
|
labels = [ids[i] for i in labels]
|
||||||
data = {
|
data = {
|
||||||
"base": target_branch,
|
"base": target_branch,
|
||||||
"head": f"{source_owner}:{source_branch}",
|
"head": f"{source_owner}:{source_branch}",
|
||||||
"title": title,
|
"title": title,
|
||||||
"body": description,
|
"body": description,
|
||||||
|
"labels": labels,
|
||||||
}
|
}
|
||||||
response = conn.request("POST", url, json_data=data)
|
response = conn.request("POST", url, json_data=data)
|
||||||
obj = cls(response.json(), response=response, conn=conn)
|
obj = cls(response.json(), response=response, conn=conn)
|
||||||
|
|||||||
Reference in New Issue
Block a user