From 053cede58121f659ed6dc8925a9b381b115acd63 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 31 Aug 2022 07:22:56 +0530 Subject: [PATCH] Use git rev-parse to get nightly commit hash --- publish.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/publish.py b/publish.py index cae4b7381..12c60af14 100755 --- a/publish.py +++ b/publish.py @@ -269,13 +269,7 @@ 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' - 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() + commit = subprocess.check_output(['git', 'rev-parse', '--verify', '--end-of-options', 'master^{commit}']).decode('utf-8').strip() self.patch( url, 'Failed to update nightly release description', body=f'Nightly release, generated on: {now} from commit: {commit}.'