Skip to content

Commit 02c2124

Browse files
authored
Handle no 30 days commit (#78)
1 parent 7326885 commit 02c2124

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
@@ -49,18 +49,22 @@ def get_completion(
4949

5050
if completion:
5151
# Fetch commit from before 30 days ago and checkout
52-
commit = next(
53-
clone_repo.iter_commits('HEAD', max_count=1, before='30 days ago')
54-
)
55-
clone_repo.git.checkout(commit.hexsha)
56-
with TemporaryDirectory() as tmpdir:
57-
month_ago_completion = potodo.merge_and_scan_path(
58-
clone_path,
59-
pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'),
60-
merge_path=Path(tmpdir),
61-
hide_reserved=False,
62-
api_url='',
63-
).completion
52+
try:
53+
commit = next(
54+
clone_repo.iter_commits('HEAD', max_count=1, before='30 days ago')
55+
)
56+
except StopIteration:
57+
month_ago_completion = 0.0
58+
else:
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
6468
else:
6569
month_ago_completion = 0.0
6670

0 commit comments

Comments
 (0)