mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix: Remove nested git repositories before adding files in SWE-bench (#6536)
Co-authored-by: Xingyao Wang <xingyao@all-hands.dev>
This commit is contained in:
parent
996757f4f5
commit
8a58e724c6
@ -371,6 +371,32 @@ def complete_runtime(
|
|||||||
f'Failed to git config --global core.pager "": {str(obs)}',
|
f'Failed to git config --global core.pager "": {str(obs)}',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# First check for any git repositories in subdirectories
|
||||||
|
action = CmdRunAction(command='find . -type d -name .git -not -path "./.git"')
|
||||||
|
action.set_hard_timeout(600)
|
||||||
|
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||||
|
obs = runtime.run_action(action)
|
||||||
|
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||||
|
assert_and_raise(
|
||||||
|
isinstance(obs, CmdOutputObservation) and obs.exit_code == 0,
|
||||||
|
f'Failed to find git repositories: {str(obs)}',
|
||||||
|
)
|
||||||
|
|
||||||
|
git_dirs = [p for p in obs.content.strip().split('\n') if p]
|
||||||
|
if git_dirs:
|
||||||
|
# Remove all .git directories in subdirectories
|
||||||
|
for git_dir in git_dirs:
|
||||||
|
action = CmdRunAction(command=f'rm -rf "{git_dir}"')
|
||||||
|
action.set_hard_timeout(600)
|
||||||
|
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||||
|
obs = runtime.run_action(action)
|
||||||
|
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
|
||||||
|
assert_and_raise(
|
||||||
|
isinstance(obs, CmdOutputObservation) and obs.exit_code == 0,
|
||||||
|
f'Failed to remove git directory {git_dir}: {str(obs)}',
|
||||||
|
)
|
||||||
|
|
||||||
|
# add all files
|
||||||
action = CmdRunAction(command='git add -A')
|
action = CmdRunAction(command='git add -A')
|
||||||
action.set_hard_timeout(600)
|
action.set_hard_timeout(600)
|
||||||
logger.info(action, extra={'msg_type': 'ACTION'})
|
logger.info(action, extra={'msg_type': 'ACTION'})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user