|
@@ -58,9 +58,22 @@ def metadata_from_data_store(d):
|
|
|
|
|
|
def git_rev_info(path):
|
|
|
"""Get git revision information as a dict"""
|
|
|
- from git import Repo, InvalidGitRepositoryError, NoSuchPathError
|
|
|
-
|
|
|
info = OrderedDict()
|
|
|
+
|
|
|
+ try:
|
|
|
+ from git import Repo, InvalidGitRepositoryError, NoSuchPathError
|
|
|
+ except ImportError:
|
|
|
+ import subprocess
|
|
|
+ try:
|
|
|
+ info['branch'] = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=path).decode('utf-8').strip()
|
|
|
+ except subprocess.CalledProcessError:
|
|
|
+ pass
|
|
|
+ try:
|
|
|
+ info['commit'] = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=path).decode('utf-8').strip()
|
|
|
+ except subprocess.CalledProcessError:
|
|
|
+ pass
|
|
|
+ return info
|
|
|
+
|
|
|
try:
|
|
|
repo = Repo(path, search_parent_directories=True)
|
|
|
except (InvalidGitRepositoryError, NoSuchPathError):
|