Handle corner case where no commit logs are fetched.

This could happen if user specifies "accepted_statuses=['404']", and the current behaviour raises a KeyError exception from "last_result['log']".

Change-Id: Icebb8ac3b656548892bbf729e5df0cd5e5223ada
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6352740
Auto-Submit: Keybo Qian <keybo@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Keybo Qian <keybo@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
changes/40/6352740/4
Keybo Qian 3 months ago committed by LUCI CQ
parent 454f6ce8e2
commit c3129d4f4f

@ -75,9 +75,9 @@ def fetch_log_with_paging(query_params, limit, fetch):
"""
# Log api returns {'log': [list of commits], 'next': hash}.
last_result = fetch(query_params)
commits = last_result['log']
while last_result.get('next') and len(commits) < limit:
query_params['s'] = last_result.get('next')
commits = last_result.get('log', [])
while (next_page := last_result.get('next', '')) and len(commits) < limit:
query_params['s'] = next_page
last_result = fetch(query_params)
# The first commit in `last_result` is not necessarily the parent of the
# last commit in result so far! This is because log command can be done on

Loading…
Cancel
Save