in backend/code_coverage_backend/hgmo.py [0:0]
def hgmo_pushes(repository, min_push_id, nb_pages, chunk_size=8):
"""
HGMO helper to list all pushes in a limited number of pages
"""
params = {"version": 2}
if min_push_id is not None:
assert isinstance(min_push_id, int)
params["startID"] = min_push_id
params["endID"] = min_push_id + chunk_size
for page in range(nb_pages):
r = requests.get(
HGMO_PUSHES_URL.format(repository=repository),
params=params,
headers={"User-Agent": "code-coverage-backend"},
)
data = r.json()
# Sort pushes to go from oldest to newest
pushes = sorted(
[(int(push_id), push) for push_id, push in data["pushes"].items()],
key=lambda p: p[0],
)
if not pushes:
return
for push in pushes:
yield push
newest = pushes[-1][0]
params["startID"] = newest
params["endID"] = newest + chunk_size