mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 23:08:04 -05:00
(Hotfix): Branch pagination for GitLab (#10710)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
4
.github/workflows/ghcr-build.yml
vendored
4
.github/workflows/ghcr-build.yml
vendored
@@ -225,7 +225,7 @@ jobs:
|
|||||||
SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \
|
SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \
|
||||||
TEST_IN_CI=true \
|
TEST_IN_CI=true \
|
||||||
RUN_AS_OPENHANDS=false \
|
RUN_AS_OPENHANDS=false \
|
||||||
poetry run pytest -n 7 -raRs --reruns 2 --reruns-delay 5 -s ./tests/runtime --ignore=tests/runtime/test_browsergym_envs.py --durations=10
|
poetry run pytest -n 0 -raRs --reruns 2 --reruns-delay 5 -s ./tests/runtime --ignore=tests/runtime/test_browsergym_envs.py --durations=10
|
||||||
env:
|
env:
|
||||||
DEBUG: "1"
|
DEBUG: "1"
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ jobs:
|
|||||||
SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \
|
SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \
|
||||||
TEST_IN_CI=true \
|
TEST_IN_CI=true \
|
||||||
RUN_AS_OPENHANDS=true \
|
RUN_AS_OPENHANDS=true \
|
||||||
poetry run pytest -n 7 -raRs --reruns 2 --reruns-delay 5 -s ./tests/runtime --ignore=tests/runtime/test_browsergym_envs.py --durations=10
|
poetry run pytest -n 0 -raRs --reruns 2 --reruns-delay 5 -s ./tests/runtime --ignore=tests/runtime/test_browsergym_envs.py --durations=10
|
||||||
env:
|
env:
|
||||||
DEBUG: "1"
|
DEBUG: "1"
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,9 @@ class GitLabService(BaseGitService, GitService):
|
|||||||
if 'Link' in response.headers:
|
if 'Link' in response.headers:
|
||||||
headers['Link'] = response.headers['Link']
|
headers['Link'] = response.headers['Link']
|
||||||
|
|
||||||
|
if 'X-Total' in response.headers:
|
||||||
|
headers['X-Total'] = response.headers['X-Total']
|
||||||
|
|
||||||
content_type = response.headers.get('Content-Type', '')
|
content_type = response.headers.get('Content-Type', '')
|
||||||
if 'application/json' in content_type:
|
if 'application/json' in content_type:
|
||||||
return response.json(), headers
|
return response.json(), headers
|
||||||
@@ -599,12 +602,11 @@ class GitLabService(BaseGitService, GitService):
|
|||||||
)
|
)
|
||||||
branches.append(branch)
|
branches.append(branch)
|
||||||
|
|
||||||
# Parse pagination headers
|
|
||||||
has_next_page = False
|
has_next_page = False
|
||||||
total_count = None
|
total_count = None
|
||||||
|
if headers.get('Link', ''):
|
||||||
if 'X-Next-Page' in headers and headers['X-Next-Page']:
|
|
||||||
has_next_page = True
|
has_next_page = True
|
||||||
|
|
||||||
if 'X-Total' in headers:
|
if 'X-Total' in headers:
|
||||||
try:
|
try:
|
||||||
total_count = int(headers['X-Total'])
|
total_count = int(headers['X-Total'])
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ async def test_get_paginated_branches_gitlab_headers_and_parsing():
|
|||||||
]
|
]
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'X-Next-Page': '3', # indicates has next page
|
|
||||||
'X-Total': '42',
|
'X-Total': '42',
|
||||||
|
'Link': '<https://gitlab.example.com/api/v4/projects/group%2Frepo/repository/branches?page=3&per_page=2>; rel="next"', # indicates has next page
|
||||||
}
|
}
|
||||||
|
|
||||||
with patch.object(service, '_make_request', return_value=(mock_response, headers)):
|
with patch.object(service, '_make_request', return_value=(mock_response, headers)):
|
||||||
|
|||||||
Reference in New Issue
Block a user