|
17 | 17 | from packit_service.constants import CONTACTS_URL, DOCS_APPROVAL_URL, NOTIFICATION_REPO |
18 | 18 | from packit_service.events import ( |
19 | 19 | github, |
| 20 | + gitlab, |
| 21 | + pagure, |
20 | 22 | ) |
21 | 23 | from packit_service.models import ( |
22 | 24 | AllowlistModel, |
23 | 25 | AllowlistStatus, |
24 | 26 | GithubInstallationModel, |
25 | 27 | ) |
26 | | -from packit_service.utils import get_packit_commands_from_comment |
| 28 | +from packit_service.utils import ( |
| 29 | + get_packit_commands_from_comment, # , get_pr_comment_parser, get_pr_comment_parser_fedora_ci |
| 30 | +) |
27 | 31 | from packit_service.worker.allowlist import Allowlist |
28 | 32 | from packit_service.worker.checker.abstract import Checker |
29 | 33 | from packit_service.worker.checker.forges import IsIssueInNotificationRepoChecker |
|
35 | 39 | from packit_service.worker.mixin import ( |
36 | 40 | ConfigFromEventMixin, |
37 | 41 | GetIssueMixin, |
| 42 | + GetPullRequestMixin, |
38 | 43 | PackitAPIWithDownstreamMixin, |
39 | 44 | ) |
40 | 45 | from packit_service.worker.reporting import create_issue_if_needed |
@@ -279,3 +284,61 @@ def verify(self, namespace: str, fas_account: str) -> TaskResults: |
279 | 284 | self.issue.comment(msg) |
280 | 285 |
|
281 | 286 | return TaskResults(success=True, details={"msg": msg}) |
| 287 | + |
| 288 | + |
| 289 | +@reacts_to(event=github.pr.Comment) |
| 290 | +@reacts_to(event=gitlab.mr.Comment) |
| 291 | +@reacts_to(event=pagure.pr.Comment) |
| 292 | +class GitPullRequestHelpHandler( |
| 293 | + JobHandler, |
| 294 | + PackitAPIWithDownstreamMixin, |
| 295 | + GetPullRequestMixin, |
| 296 | +): |
| 297 | + task_name = TaskName.help |
| 298 | + |
| 299 | + def __init__( |
| 300 | + self, |
| 301 | + package_config: PackageConfig, |
| 302 | + job_config: JobConfig, |
| 303 | + event: dict, |
| 304 | + ): |
| 305 | + super().__init__( |
| 306 | + package_config=package_config, |
| 307 | + job_config=job_config, |
| 308 | + event=event, |
| 309 | + ) |
| 310 | + self.sender_login = self.data.actor |
| 311 | + self.comment = self.data.event_dict.get("comment") |
| 312 | + |
| 313 | + def run(self) -> TaskResults: |
| 314 | + help_message = "PLACEHOLDER_HELP_MESSAGE_DELETE_ME_LATER" |
| 315 | + |
| 316 | + # TODO UNCOMMENT THE FOLLOWING ONCE COMMENT PARSERS ARE AVAILABLE |
| 317 | + # commands = get_packit_commands_from_comment( |
| 318 | + # self.comment, # type: ignore |
| 319 | + # self.service_config.comment_command_prefix, |
| 320 | + # ) |
| 321 | + # if self.comment.startswith("/packit-ci"): # type: ignore |
| 322 | + # parser = get_pr_comment_parser_fedora_ci( |
| 323 | + # prog=HELP_COMMENT_PROG_FEDORA_CI, |
| 324 | + # description=HELP_COMMENT_DESCRIPTION, |
| 325 | + # epilog=HELP_COMMENT_EPILOG, |
| 326 | + # ) |
| 327 | + # else: |
| 328 | + # parser = get_pr_comment_parser( |
| 329 | + # prog=HELP_COMMENT_PROG, |
| 330 | + # description=HELP_COMMENT_DESCRIPTION, |
| 331 | + # epilog=HELP_COMMENT_EPILOG, |
| 332 | + # ) |
| 333 | + |
| 334 | + # # prevent help message from being printed to stdout |
| 335 | + # # save help message to buffer |
| 336 | + # help_message_buffer = io.StringIO() |
| 337 | + # backup_stdout = sys.stdout |
| 338 | + # sys.stdout = help_message_buffer |
| 339 | + # parser.print_help() |
| 340 | + # sys.stdout = backup_stdout |
| 341 | + # help_message = help_message_buffer.getvalue() |
| 342 | + |
| 343 | + self.pr.comment(body=help_message) |
| 344 | + return TaskResults(success=True, details={"msg": help_message}) |
0 commit comments