Use git rev-parse to get nightly commit hash

This commit is contained in:
Kovid Goyal 2022-08-31 07:22:56 +05:30
parent fca0999814
commit 053cede581
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -269,13 +269,7 @@ class GitHub(Base): # {{{
def update_nightly_description(self, release_id: int) -> None: def update_nightly_description(self, release_id: int) -> None:
url = f'{self.url_base}/{release_id}' url = f'{self.url_base}/{release_id}'
now = str(datetime.datetime.utcnow()).split('.')[0] + ' UTC' now = str(datetime.datetime.utcnow()).split('.')[0] + ' UTC'
try: commit = subprocess.check_output(['git', 'rev-parse', '--verify', '--end-of-options', 'master^{commit}']).decode('utf-8').strip()
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( self.patch(
url, 'Failed to update nightly release description', url, 'Failed to update nightly release description',
body=f'Nightly release, generated on: {now} from commit: {commit}.' body=f'Nightly release, generated on: {now} from commit: {commit}.'