From 96703c23c8d480dbab02190f6c4043736de6cbcc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 23 Jun 2019 07:36:03 +0530 Subject: [PATCH] Deal with .git being a file when getting the VCS commit hash during building --- setup.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index bf01f31ec..71ae55fb6 100755 --- a/setup.py +++ b/setup.py @@ -308,9 +308,15 @@ def get_vcs_rev_defines(): try: rev = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip() except FileNotFoundError: - with open('.git/refs/heads/master') as f: - rev = f.read() - ans.append('KITTY_VCS_REV="{}"'.format(rev)) + try: + with open('.git/refs/heads/master') as f: + rev = f.read() + except NotADirectoryError: + gitloc = open('.git').read() + with open(os.path.join(gitloc, '/refs/heads/master')) as f: + rev = f.read() + + ans.append('KITTY_VCS_REV="{}"'.format(rev.strip())) return ans