3838)
3939
4040logger = logging .getLogger (__name__ )
41+ RUN_TASK_RE = re .compile (r"run-task(-(git|hg))?$" )
4142
4243
4344def get_image_digest (image_name : str ) -> str :
@@ -418,6 +419,11 @@ def _resolve_image(image: Union[str, dict[str, str]], graph_config: GraphConfig)
418419 return load_image_by_task_id (image_task_id )
419420
420421
422+ def _is_run_task (task_def : dict [str , str ]):
423+ cmd = task_def ["payload" ].get ("command" ) # type: ignore
424+ return cmd and re .search (RUN_TASK_RE , cmd [0 ])
425+
426+
421427def load_task (
422428 graph_config : GraphConfig ,
423429 task : Union [str , dict [str , Any ]],
@@ -465,9 +471,9 @@ def load_task(
465471
466472 return 1
467473
468- task_command = task_def [ "payload" ]. get ( "command" ) # type: ignore
469- if interactive and ( not task_command or not task_command [ 0 ]. endswith ( "run-task" )) :
470- logger .error ("Only tasks using `run-task` are supported with interactive!" )
474+ is_run_task = _is_run_task ( task_def )
475+ if interactive and not is_run_task :
476+ logger .error ("Only tasks using `run-task` are supported with -- interactive!" )
471477 return 1
472478
473479 try :
@@ -477,6 +483,7 @@ def load_task(
477483 logger .exception (e )
478484 return 1
479485
486+ task_command = task_def ["payload" ].get ("command" ) # type: ignore
480487 exec_command = task_cwd = None
481488 if interactive :
482489 # Remove the payload section of the task's command. This way run-task will
0 commit comments