Skip to content

Conversation

@betulependule
Copy link
Contributor

@betulependule betulependule commented Oct 6, 2025

A new job handler has been created so that packit-service now has the ability to respond to the help command in PR comments. The bot then should automatically generate a comment, which contains a help message that includes the usage, link to documentation and contacts. A test for Github PR was made to test this new functionality.

TODO:

  • Update or write new documentation in packit/packit.dev.
  • In the help message, add reference to /packit-ci when user uses /packit and the other way around. This is in case the user uses /packit when they should be using /packit-ci and vice versa.

Fixes #1668

Related to

Merge after #2850

RELEASE NOTES BEGIN

Packit-service now supports the help command in PR comments.

RELEASE NOTES END

@softwarefactory-project-zuul
Copy link
Contributor

@betulependule betulependule force-pushed the help-pr-comment-command branch from 457d872 to 7cb22ab Compare November 26, 2025 10:09
@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

@betulependule
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR introduces a new handler for the help command in PR comments, which is a great addition for user experience. The implementation is straightforward and follows existing patterns in the codebase. The changes are well-contained and include corresponding tests.

I've left a few comments with suggestions for improvement, mainly around code clarity, maintainability, and a potential thread-safety issue in the planned implementation. Once the dependent PR is merged and the commented-out code is enabled, the suggestion regarding thread-safety will be particularly important to address.

Overall, this is a solid contribution.

@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

@betulependule betulependule force-pushed the help-pr-comment-command branch from 6e25b11 to efb691b Compare November 26, 2025 12:37
@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

@betulependule
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new GitPullRequestHelpHandler to respond to /packit help commands in pull request comments. The implementation is well-structured, adding the necessary handler, task, and event routing. The changes also include integration tests for the new functionality on GitHub and Pagure.

My review focuses on improving the robustness of the command detection logic. I've identified a couple of areas where handling of different command prefixes (especially for staging environments) could be improved to prevent issues in the future. One of these is in the active code and could cause bugs in staging, while the other is in commented-out code that is planned for a future update. Addressing these will make the new feature more reliable across all environments.

Comment on lines 1142 to 1151
packit_comment_command_prefix = (
"/packit-ci" if comment.startswith("/packit-ci") else "/packit"
)

command = get_packit_commands_from_comment(
comment,
packit_comment_command_prefix,
)

return bool(command and command[0] == PACKIT_HELP_COMMAND)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The logic to detect the help command is not robust enough. It doesn't handle staging prefixes like /packit-stg or /packit-ci-stg, and it can fail if the comment has leading whitespace since comment.startswith is used on the raw comment string.

A better approach would be to iterate through all possible prefixes and use get_packit_commands_from_comment to check for the help command. This would also make the logic more resilient to comment formatting.

Consider improving the test cases in tests/integration/test_pr_comment.py to cover staging prefixes to catch such issues in the future.

Suggested change
packit_comment_command_prefix = (
"/packit-ci" if comment.startswith("/packit-ci") else "/packit"
)
command = get_packit_commands_from_comment(
comment,
packit_comment_command_prefix,
)
return bool(command and command[0] == PACKIT_HELP_COMMAND)
prefixes = ("/packit-ci-stg", "/packit-ci", "/packit-stg", "/packit")
for prefix in prefixes:
command = get_packit_commands_from_comment(
comment,
prefix,
)
if command and command[0] == PACKIT_HELP_COMMAND:
return True
return False

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "-stg" suffixes definitely need to be taken into account. However, I don't think I like the trial and error for loop. I'll try a different solution.

@betulependule betulependule force-pushed the help-pr-comment-command branch from 1df9cdb to a4ae68a Compare November 28, 2025 10:50
@betulependule
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new GitPullRequestHelpHandler to respond to /packit help commands in pull request comments across GitHub, GitLab, and Pagure. This is a valuable feature for improving user experience. The implementation is well-structured, adding a new handler, a Celery task, and updating the job processing logic. Integration tests for GitHub and Pagure are included. My review focuses on a minor typo, improving test coverage by adding a GitLab test, and correcting type hints for better code quality.

@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

The previously used variable seemed to always be initialized with
the "/packit" value, which would result in incorrect behaviour
in Fedora CI as the expected value in this case would be
"/packit-ci" instead. Correct value should now be in use.
@betulependule betulependule force-pushed the help-pr-comment-command branch from 3ca3c90 to 499c4f2 Compare January 27, 2026 10:28
@centosinfra-prod-github-app
Copy link
Contributor

There is now a reference to /packit-ci when user uses /packit and
the other way around. This is in case the user uses /packit when
they should be using /packit-ci and vice versa.
@betulependule betulependule force-pushed the help-pr-comment-command branch from 76f128d to 5636422 Compare January 27, 2026 11:48
@centosinfra-prod-github-app
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a /packit help comment command

1 participant