Skip to content

Commit

Permalink
Add Git LFS and clone depth support
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotra5 committed Feb 20, 2025
1 parent 0180ce7 commit bddf667
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions openhands/resolver/resolve_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,23 @@ async def resolve_issue(
# checkout the repo
repo_dir = os.path.join(output_dir, 'repo')
if not os.path.exists(repo_dir):
checkout_output = subprocess.check_output(
[
'git',
'clone',
issue_handler.get_clone_url(),
f'{output_dir}/repo',
]
).decode('utf-8')
# Configure Git LFS to skip downloading large files if requested
if os.getenv('GIT_LFS_SKIP_SMUDGE') == '1':
subprocess.check_output(['git', 'config', '--global', 'filter.lfs.smudge', 'git-lfs smudge --skip'])
subprocess.check_output(['git', 'config', '--global', 'filter.lfs.process', 'git-lfs filter-process --skip'])

# Build git clone command
clone_cmd = ['git', 'clone']

# Add --depth if requested
if depth := os.getenv('GIT_CLONE_DEPTH'):
clone_cmd.extend(['--depth', depth])

# Add repository URL and destination
clone_cmd.extend([issue_handler.get_clone_url(), f'{output_dir}/repo'])

# Execute git clone
checkout_output = subprocess.check_output(clone_cmd).decode('utf-8')
if 'fatal' in checkout_output:
raise RuntimeError(f'Failed to clone repository: {checkout_output}')

Expand Down

0 comments on commit bddf667

Please sign in to comment.