Skip to content

Commit

Permalink
Change parsing of comment command arguments (#2346)
Browse files Browse the repository at this point in the history
Change parsing of comment command arguments

So that if there are multiple arguments in the command, all of them are separate items of list returned by get_packit_commands_from_comment. This fixed parsing of resolved bugzillas in comment like '/packit pull-from-upstream --with-pr-config --resolved-bugs rhbz#123'

RELEASE NOTES BEGIN
We have fixed parsing of resolved bugzillas in comments with multiple arguments specified e.g. /packit pull-from-upstream --with-pr-config --resolved-bugs rhbz#123
RELEASE NOTES END

Reviewed-by: Nikola Forró
Reviewed-by: Maja Massarini
Reviewed-by: Laura Barcziová
  • Loading branch information
softwarefactory-project-zuul[bot] authored Feb 15, 2024
2 parents 3d581a2 + e20adf8 commit 1153d33
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packit_service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def get_packit_commands_from_comment(
comment_lines = comment_parts.split("\n")

for line in filter(None, map(str.strip, comment_lines)):
(packit_mark, *packit_command) = line.split(maxsplit=3)
# packit_command[0] has the first cmd and [1] has the second, if needed.
(packit_mark, *packit_command) = line.split()
# packit_command[0] has the cmd and other list items are the arguments
if packit_mark == packit_comment_command_prefix and packit_command:
return packit_command

Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/events/pagure.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get_packages_config(self) -> Optional[PackageConfig]:
if not commands:
return super().get_packages_config()
command = commands[0]
args = commands[1] if len(commands) > 1 else ""
args = commands[1:] if len(commands) > 1 else []
if command == "pull-from-upstream" and "--with-pr-config" in args:
# take packages config from the corresponding branch
# for pull-from-upstream --with-pr-config
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_pr_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2600,7 +2600,7 @@ def test_bodhi_update_retrigger_via_dist_git_pr_comment(pagure_pr_comment_added)
def test_pull_from_upstream_retrigger_via_dist_git_pr_comment(pagure_pr_comment_added):
pagure_pr_comment_added["pullrequest"]["comments"][0][
"comment"
] = "/packit pull-from-upstream --resolved-bugs rhbz#123,rhbz#124"
] = "/packit pull-from-upstream --with-pr-config --resolved-bugs rhbz#123,rhbz#124"

model = flexmock(status="queued", id=1234, branch="main")
flexmock(SyncReleaseTargetModel).should_receive("create").with_args(
Expand Down

0 comments on commit 1153d33

Please sign in to comment.