Skip to content

Commit 83fb13f

Browse files
committed
Use the epilog note about Fedora CI only in the context of Pagure
With the previous implementation, when a user would use the `/packit help` command, the epilog would mention the Fedora CI `/packit-cit help` command, which would confuse users who do not know what Fedora CI even is. The note is now only added when the `/packit help` command is used in the context of Pagure.
1 parent 216515e commit 83fb13f

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

packit_service/constants.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@
2525
HELP_COMMENT_PROG_FEDORA_CI = "/packit-ci"
2626
HELP_COMMENT_PROG_FEDORA_CI_STG = "/packit-ci-stg"
2727
HELP_COMMENT_DESCRIPTION = ""
28-
HELP_COMMENT_EPILOG = (
29-
"**Please note**: \n - {note}\n\n"
28+
HELP_COMMENT_NOTE = "**Please note**: \n - {note_content}\n"
29+
HELP_COMMENT_CONTACT = (
3030
"**Contact**:\n"
3131
" - *Email*: hello@packit.dev\n"
3232
" - *Matrix*: #packit:fedora.im\n"
33-
" - *Mastodon*: @packit@fosstodon.org\n\n"
34-
"**Documentation**: \n - {docs}"
33+
" - *Mastodon*: @packit@fosstodon.org\n"
3534
)
35+
HELP_COMMENT_DOCS = "**Documentation**: \n - {docs_url}"
36+
HELP_COMMENT_EPILOG = "{note}" + HELP_COMMENT_CONTACT + HELP_COMMENT_DOCS
37+
3638
HELP_NOTE = (
3739
"`/packit` commands interact with the opt-in packit jobs "
3840
"(e.g. `propose-downstream`, `pull-from-upstream`). "

packit_service/worker/handlers/forges.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from abc import ABC, abstractmethod
1111
from typing import Optional
1212

13+
from ogr.services.pagure import PagureProject
1314
from packit.api import PackitAPI
1415
from packit.config import (
1516
Deployment,
@@ -25,6 +26,7 @@
2526
DOCS_URL_FEDORA_CI,
2627
HELP_COMMENT_DESCRIPTION,
2728
HELP_COMMENT_EPILOG,
29+
HELP_COMMENT_NOTE,
2830
HELP_COMMENT_PROG,
2931
HELP_COMMENT_PROG_FEDORA_CI,
3032
HELP_COMMENT_PROG_FEDORA_CI_STG,
@@ -340,28 +342,34 @@ def run(self) -> TaskResults:
340342
prog=HELP_COMMENT_PROG_FEDORA_CI_STG,
341343
description=HELP_COMMENT_DESCRIPTION,
342344
)
343-
epilog = HELP_COMMENT_EPILOG.format(note=HELP_NOTE_FEDORA_CI, docs=DOCS_URL_FEDORA_CI)
345+
epilog = HELP_COMMENT_EPILOG.format(
346+
note=self.get_epilog_note_fedora_ci(), docs_url=DOCS_URL_FEDORA_CI
347+
)
344348

345349
elif self.comment.startswith("/packit-ci"): # type: ignore
346350
parser = get_comment_parser_fedora_ci(
347351
prog=HELP_COMMENT_PROG_FEDORA_CI,
348352
description=HELP_COMMENT_DESCRIPTION,
349353
)
350-
epilog = HELP_COMMENT_EPILOG.format(note=HELP_NOTE_FEDORA_CI, docs=DOCS_URL_FEDORA_CI)
354+
epilog = HELP_COMMENT_EPILOG.format(
355+
note=self.get_epilog_note_fedora_ci(), docs_url=DOCS_URL_FEDORA_CI
356+
)
351357

352358
elif self.comment.startswith("/packit-stg"): # type: ignore
353359
parser = get_comment_parser(
354360
prog=HELP_COMMENT_PROG_STG,
355361
description=HELP_COMMENT_DESCRIPTION,
356362
)
357-
epilog = HELP_COMMENT_EPILOG.format(note=HELP_NOTE, docs=DOCS_URL)
363+
364+
epilog = HELP_COMMENT_EPILOG.format(note=self.get_epilog_note(), docs_url=DOCS_URL)
358365

359366
else:
360367
parser = get_comment_parser(
361368
prog=HELP_COMMENT_PROG,
362369
description=HELP_COMMENT_DESCRIPTION,
363370
)
364-
epilog = HELP_COMMENT_EPILOG.format(note=HELP_NOTE, docs=DOCS_URL)
371+
372+
epilog = HELP_COMMENT_EPILOG.format(note=self.get_epilog_note(), docs_url=DOCS_URL)
365373

366374
body = break_lines_in_text(
367375
parser.format_help(), sep=",", max_line_length=COMMENT_MAX_LINE_LENGTH
@@ -372,6 +380,16 @@ def run(self) -> TaskResults:
372380

373381
return TaskResults(success=True, details={"msg": help_message})
374382

383+
def get_epilog_note(self) -> str:
384+
return (
385+
HELP_COMMENT_NOTE.format(note_content=HELP_NOTE)
386+
if isinstance(self.project, PagureProject)
387+
else ""
388+
)
389+
390+
def get_epilog_note_fedora_ci(self) -> str:
391+
return HELP_COMMENT_NOTE.format(note_content=HELP_NOTE_FEDORA_CI)
392+
375393

376394
@reacts_to(event=github.pr.Comment)
377395
@reacts_to(event=gitlab.mr.Comment)

0 commit comments

Comments
 (0)