Retry reading HEAD commit

This commit is contained in:
Kovid Goyal
2022-03-12 08:14:06 +05:30
parent f6fb36c58a
commit 9687318b22

View File

@@ -273,8 +273,13 @@ class GitHub(Base): # {{{
def update_nightly_description(self, release_id: int) -> None:
url = f'{self.url_base}/{release_id}'
now = str(datetime.datetime.utcnow()).split('.')[0] + ' UTC'
with open('.git/refs/heads/master') as f:
commit = f.read().strip()
try:
with open('.git/refs/heads/master') as f:
commit = f.read().strip()
except FileNotFoundError:
time.sleep(1)
with open('.git/refs/heads/master') as f:
commit = f.read().strip()
self.patch(
url, 'Failed to update nightly release description',
body=f'Nightly release, generated on: {now} from commit: {commit}.'