Skip to content

Commit d74457d

Browse files
committed
Support setting labels in gitea_api.PullRequest.create()
1 parent 7b74682 commit d74457d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

osc/gitea_api/pr.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def create(
345345
source_branch: str,
346346
title: str,
347347
description: Optional[str] = None,
348+
labels: Optional[List[str]] = None,
348349
) -> "PullRequest":
349350
"""
350351
Create a pull request to ``owner``/``repo`` to the ``base`` branch.
@@ -358,13 +359,18 @@ def create(
358359
:param source_branch: Name of the source branch in the source (forked) repo.
359360
:param title: Pull request title.
360361
:param description: Pull request description.
362+
:param labels: List of labels to be associated with the pull request.
361363
"""
362364
url = conn.makeurl("repos", target_owner, target_repo, "pulls")
365+
if labels:
366+
ids = cls._get_label_ids(conn, target_owner, target_repo)
367+
labels = [ids[i] for i in labels]
363368
data = {
364369
"base": target_branch,
365370
"head": f"{source_owner}:{source_branch}",
366371
"title": title,
367372
"body": description,
373+
"labels": labels,
368374
}
369375
response = conn.request("POST", url, json_data=data)
370376
obj = cls(response.json(), response=response, conn=conn)

0 commit comments

Comments
 (0)