Skip to content

Commit 1153d33

Browse files
Change parsing of comment command arguments (#2346)
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á
2 parents 3d581a2 + e20adf8 commit 1153d33

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

packit_service/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ def get_packit_commands_from_comment(
200200
comment_lines = comment_parts.split("\n")
201201

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

packit_service/worker/events/pagure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def get_packages_config(self) -> Optional[PackageConfig]:
134134
if not commands:
135135
return super().get_packages_config()
136136
command = commands[0]
137-
args = commands[1] if len(commands) > 1 else ""
137+
args = commands[1:] if len(commands) > 1 else []
138138
if command == "pull-from-upstream" and "--with-pr-config" in args:
139139
# take packages config from the corresponding branch
140140
# for pull-from-upstream --with-pr-config

tests/integration/test_pr_comment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2600,7 +2600,7 @@ def test_bodhi_update_retrigger_via_dist_git_pr_comment(pagure_pr_comment_added)
26002600
def test_pull_from_upstream_retrigger_via_dist_git_pr_comment(pagure_pr_comment_added):
26012601
pagure_pr_comment_added["pullrequest"]["comments"][0][
26022602
"comment"
2603-
] = "/packit pull-from-upstream --resolved-bugs rhbz#123,rhbz#124"
2603+
] = "/packit pull-from-upstream --with-pr-config --resolved-bugs rhbz#123,rhbz#124"
26042604

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

0 commit comments

Comments
 (0)