Skip to content

Commit a8e8f6e

Browse files
Update the epilog of the help comment (#3124)
Update the epilog of the help comment This PR introduces some small edits to the epilog of the help comment. The epilog no longer references .packit.yaml and instead, uses a more generic term. The note referencing /packit-ci is now only added when the user uses /packit help on Pagure. Many users of Packit don't know what Fedora CI even is, so mentioning it on GitHub and Gitlab made little sense. I've tested the fixes on a local deployment, but am not currently able to test it after applying the latest refactoring changes as I am hitting a Temporary failure in name resolution. I'll re-test it once I am able to. TODO: Test on local deployment Not sure if this is relevant enough to be mentioned in the blog post. If yes, here are the release notes below. Ignore this otherwise: RELEASE NOTES BEGIN In instances where the help comment (created in response to /packit help) would reference the need for a configuration file, Packit now uses a generic term, reflecting support for all valid configuration file names and replacing the previous specific mention of .packit.yaml. The help comment also no longer references /packit-ci commands on GitHub and Gitlab as these commands are not relevant to users on these platforms. RELEASE NOTES END Reviewed-by: gemini-code-assist[bot] Reviewed-by: Alžběta Kučerová Reviewed-by: Nikola Forró Reviewed-by: Matej Focko
2 parents 737a31d + 0a6305e commit a8e8f6e

2 files changed

Lines changed: 52 additions & 29 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\n"
29+
HELP_COMMENT_CONTACT = (
3030
"**Contact**:\n"
3131
" - *Email*: hello@packit.dev\n"
3232
" - *Matrix*: #packit:fedora.im\n"
3333
" - *Mastodon*: @packit@fosstodon.org\n\n"
34-
"**Documentation**: \n - {docs}"
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`). "
@@ -46,7 +48,7 @@
4648
"If you are looking for help on the opt-in packit jobs "
4749
"(e.g. `propose-downstream`, `pull-from-upstream`), "
4850
"refer to `/packit` or `/packit-stg`. "
49-
"These assume a `.packit.yaml` configuration file is present in the repo."
51+
"These assume a valid Packit configuration file is present in the repo."
5052
)
5153

5254
KOJI_PRODUCTION_BUILDS_ISSUE = "https://pagure.io/releng/issue/9801"

packit_service/worker/handlers/forges.py

Lines changed: 46 additions & 25 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,
@@ -335,43 +337,62 @@ def add_comment(self, body: str) -> None:
335337
pass
336338

337339
def run(self) -> TaskResults:
338-
if self.comment.startswith("/packit-ci-stg"): # type: ignore
339-
parser = get_comment_parser_fedora_ci(
340-
prog=HELP_COMMENT_PROG_FEDORA_CI_STG,
341-
description=HELP_COMMENT_DESCRIPTION,
342-
)
343-
epilog = HELP_COMMENT_EPILOG.format(note=HELP_NOTE_FEDORA_CI, docs=DOCS_URL_FEDORA_CI)
344-
345-
elif self.comment.startswith("/packit-ci"): # type: ignore
346-
parser = get_comment_parser_fedora_ci(
347-
prog=HELP_COMMENT_PROG_FEDORA_CI,
348-
description=HELP_COMMENT_DESCRIPTION,
349-
)
350-
epilog = HELP_COMMENT_EPILOG.format(note=HELP_NOTE_FEDORA_CI, docs=DOCS_URL_FEDORA_CI)
351-
352-
elif self.comment.startswith("/packit-stg"): # type: ignore
353-
parser = get_comment_parser(
354-
prog=HELP_COMMENT_PROG_STG,
355-
description=HELP_COMMENT_DESCRIPTION,
340+
if not self.comment:
341+
msg = (
342+
"GitCommentHelpHandler was run, but the triggering comment is missing."
343+
"Won't post a comment in response."
356344
)
357-
epilog = HELP_COMMENT_EPILOG.format(note=HELP_NOTE, docs=DOCS_URL)
345+
logger.debug(msg)
346+
return TaskResults(success=False, details={"msg": msg})
358347

348+
# Determine parameters based on comment prefix
349+
comment = self.comment
350+
351+
if comment.startswith("/packit-ci-stg"):
352+
prog = HELP_COMMENT_PROG_FEDORA_CI_STG
353+
parser_func = get_comment_parser_fedora_ci
354+
epilog_note = self.get_epilog_note_fedora_ci()
355+
docs_url = DOCS_URL_FEDORA_CI
356+
elif comment.startswith("/packit-ci"):
357+
prog = HELP_COMMENT_PROG_FEDORA_CI
358+
parser_func = get_comment_parser_fedora_ci
359+
epilog_note = self.get_epilog_note_fedora_ci()
360+
docs_url = DOCS_URL_FEDORA_CI
361+
elif comment.startswith("/packit-stg"):
362+
prog = HELP_COMMENT_PROG_STG
363+
parser_func = get_comment_parser # type: ignore[assignment]
364+
epilog_note = self.get_epilog_note()
365+
docs_url = DOCS_URL
359366
else:
360-
parser = get_comment_parser(
361-
prog=HELP_COMMENT_PROG,
362-
description=HELP_COMMENT_DESCRIPTION,
363-
)
364-
epilog = HELP_COMMENT_EPILOG.format(note=HELP_NOTE, docs=DOCS_URL)
367+
prog = HELP_COMMENT_PROG
368+
parser_func = get_comment_parser # type: ignore[assignment]
369+
epilog_note = self.get_epilog_note()
370+
docs_url = DOCS_URL
371+
372+
# Use determined parameters to create parser and epilog
373+
parser = parser_func(prog=prog, description=HELP_COMMENT_DESCRIPTION)
374+
epilog = HELP_COMMENT_EPILOG.format(note=epilog_note, docs_url=docs_url)
365375

376+
# Format and comment help message
366377
body = break_lines_in_text(
367378
parser.format_help(), sep=",", max_line_length=COMMENT_MAX_LINE_LENGTH
368379
)
369-
# put message in code block to retain formatting
380+
# Put body in code block to retain formatting
370381
help_message = f"```\n{body}\n```\n{epilog}"
371382
self.add_comment(body=help_message)
372383

373384
return TaskResults(success=True, details={"msg": help_message})
374385

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

376397
@reacts_to(event=github.pr.Comment)
377398
@reacts_to(event=gitlab.mr.Comment)

0 commit comments

Comments
 (0)