Skip to content

Commit fd33e03

Browse files
committed
handle no 30 days commit
1 parent c2e012f commit fd33e03

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

completion.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,22 @@ def get_completion(
5353

5454
if completion:
5555
# Fetch commit from before 30 days ago and checkout
56-
commit = next(
57-
clone_repo.iter_commits('HEAD', max_count=1, before='30 days ago')
58-
)
59-
clone_repo.git.checkout(commit.hexsha)
60-
with TemporaryDirectory() as tmpdir:
61-
month_ago_completion = potodo.merge_and_scan_path(
62-
clone_path,
63-
pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'),
64-
merge_path=Path(tmpdir),
65-
hide_reserved=False,
66-
api_url='',
67-
).completion
56+
try:
57+
commit = next(
58+
clone_repo.iter_commits('HEAD', max_count=1, before='30 days ago')
59+
)
60+
except StopIteration:
61+
month_ago_completion = 0.0
62+
else:
63+
clone_repo.git.checkout(commit.hexsha)
64+
with TemporaryDirectory() as tmpdir:
65+
month_ago_completion = potodo.merge_and_scan_path(
66+
clone_path,
67+
pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'),
68+
merge_path=Path(tmpdir),
69+
hide_reserved=False,
70+
api_url='',
71+
).completion
6872
else:
6973
month_ago_completion = 0.0
7074

0 commit comments

Comments
 (0)