From 4b4573ee8e52072ae1cd8c569d1c6e3cb1f967d9 Mon Sep 17 00:00:00 2001
From: karnem <mikhail.karnevskiy@desy.de>
Date: Mon, 15 Jul 2019 11:14:45 +0200
Subject: [PATCH] Use git dir

---
 xfel_calibrate/calibrate.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py
index 3cbeafba4..858060827 100755
--- a/xfel_calibrate/calibrate.py
+++ b/xfel_calibrate/calibrate.py
@@ -118,7 +118,7 @@ def deconsolize_args(args):
 def extract_title_author_version(nb):
     """ Tries to extract title, author from markdown.
 
-    Version is taken from git.
+    The version is taken from git.
     """
 
     first_md = first_markdown_cell(nb)
@@ -130,8 +130,10 @@ def extract_title_author_version(nb):
     title = title[0] if len(title) else None
     author = author[0] if len(author) else None
 
-    chdir(os.path.dirname(__file__))
-    version = check_output(["git", 'describe', '--tag']).decode('utf8')
+    git_dir = '{}/../.git'.format(os.path.dirname(__file__))
+    version = check_output(['git',
+                            '--git-dir={}'.format(git_dir),
+                            'describe', '--tag']).decode('utf8')
     version = version.replace("\n", "")
     return title, author, version
 
-- 
GitLab