@@ -371,6 +371,32 @@ def complete_runtime(
371
371
f'Failed to git config --global core.pager "": { str (obs )} ' ,
372
372
)
373
373
374
+ # First check for any git repositories in subdirectories
375
+ action = CmdRunAction (command = 'find . -type d -name .git -not -path "./.git"' )
376
+ action .set_hard_timeout (600 )
377
+ logger .info (action , extra = {'msg_type' : 'ACTION' })
378
+ obs = runtime .run_action (action )
379
+ logger .info (obs , extra = {'msg_type' : 'OBSERVATION' })
380
+ assert_and_raise (
381
+ isinstance (obs , CmdOutputObservation ) and obs .exit_code == 0 ,
382
+ f'Failed to find git repositories: { str (obs )} ' ,
383
+ )
384
+
385
+ git_dirs = [p for p in obs .content .strip ().split ('\n ' ) if p ]
386
+ if git_dirs :
387
+ # Remove all .git directories in subdirectories
388
+ for git_dir in git_dirs :
389
+ action = CmdRunAction (command = f'rm -rf "{ git_dir } "' )
390
+ action .set_hard_timeout (600 )
391
+ logger .info (action , extra = {'msg_type' : 'ACTION' })
392
+ obs = runtime .run_action (action )
393
+ logger .info (obs , extra = {'msg_type' : 'OBSERVATION' })
394
+ assert_and_raise (
395
+ isinstance (obs , CmdOutputObservation ) and obs .exit_code == 0 ,
396
+ f'Failed to remove git directory { git_dir } : { str (obs )} ' ,
397
+ )
398
+
399
+ # add all files
374
400
action = CmdRunAction (command = 'git add -A' )
375
401
action .set_hard_timeout (600 )
376
402
logger .info (action , extra = {'msg_type' : 'ACTION' })
0 commit comments