def get_pushes()

in mozperftest_tools/mozperftest_tools/utils/utils.py [0:0]


def get_pushes(project, end_id, depth, full_response=False, cache=None):
    """
    Modified version from here:
    https://searchfox.org/mozilla-central/rev/
    4d2b1f753871ce514f9dccfc5b1b5e867f499229/taskcluster/
    gecko_taskgraph/actions/util.py#123-142
    """
    pushes = []
    print("Downloading pushes...")
    while True:
        start_id = max(end_id - depth, 0)
        pushlog_url = PUSHLOG_TMPL.format(BRANCH_URLS.get(project), start_id, end_id)
        cached_filename = f"pushlog-{project}-{start_id}-{end_id}.json"
        res = _retrieve_from_cache(cached_filename, cache)
        if res is None:
            print(f"Downloading {pushlog_url}...")
            r = requests.get(pushlog_url)
            r.raise_for_status()
            res = r.json()
            _store_to_cache(res, cached_filename, cache)

        pushes = pushes + list(res["pushes"].keys())
        if len(pushes) >= depth:
            break

        end_id = start_id - 1
        start_id -= depth
        if start_id < 0:
            break
        sleep(0.01)
    print("Finished downloading pushes")
    pushes = sorted(pushes)[-depth:]
    push_dict = {push: res["pushes"][push] for push in pushes}
    return push_dict if full_response else pushes