feat: joj3 create label when create issue
All checks were successful
build / trigger-build-image (push) Successful in 12s
All checks were successful
build / trigger-build-image (push) Successful in 12s
This commit is contained in:
parent
c1f7b4bdb2
commit
1336c6f1f8
|
@ -299,6 +299,14 @@ def joj3_all_env(
|
|||
True,
|
||||
help="whether to include submitter in issue title",
|
||||
),
|
||||
issue_label_name: str = Option(
|
||||
"Kind/Testing",
|
||||
help="label name for the issue created by this command",
|
||||
),
|
||||
issue_label_color: str = Option(
|
||||
"#795548",
|
||||
help="label color for the issue created by this command",
|
||||
),
|
||||
) -> None:
|
||||
app.pretty_exceptions_enable = False
|
||||
set_settings(Settings(_env_file=env_path))
|
||||
|
@ -340,6 +348,8 @@ def joj3_all_env(
|
|||
gitea_actions_url,
|
||||
submitter_in_issue_title,
|
||||
submitter_repo_name,
|
||||
issue_label_name,
|
||||
issue_label_color,
|
||||
)
|
||||
res["issue"] = issue_number
|
||||
gitea_issue_url = f"{submitter_repo_url}/issues/{issue_number}"
|
||||
|
|
|
@ -238,6 +238,8 @@ class Teapot:
|
|||
gitea_actions_url: str,
|
||||
submitter_in_issue_title: bool,
|
||||
submitter_repo_name: str,
|
||||
issue_label_name: str,
|
||||
issue_label_color: str,
|
||||
) -> int:
|
||||
title, comment = joj3.generate_title_and_comment(
|
||||
env.joj3_output_path,
|
||||
|
@ -265,10 +267,25 @@ class Teapot:
|
|||
break
|
||||
else:
|
||||
new_issue = True
|
||||
labels = self.gitea.issue_api.issue_list_labels(
|
||||
self.gitea.org_name, submitter_repo_name
|
||||
)
|
||||
label_id = 0
|
||||
for label in labels:
|
||||
if label.name == issue_label_name:
|
||||
label_id = label.id
|
||||
break
|
||||
else:
|
||||
label = self.gitea.issue_api.issue_create_label(
|
||||
self.gitea.org_name,
|
||||
submitter_repo_name,
|
||||
body={"name": issue_label_name, "color": issue_label_color},
|
||||
)
|
||||
label_id = label.id
|
||||
joj3_issue = self.gitea.issue_api.issue_create_issue(
|
||||
self.gitea.org_name,
|
||||
submitter_repo_name,
|
||||
body={"title": title, "body": comment},
|
||||
body={"title": title, "body": comment, "labels": [label_id]},
|
||||
)
|
||||
logger.info(f"created joj3 issue: #{joj3_issue.number}")
|
||||
gitea_issue_url = joj3_issue.html_url
|
||||
|
|
Loading…
Reference in New Issue
Block a user