summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Server/Plugins/Git.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/lib/Server/Plugins/Git.py b/src/lib/Server/Plugins/Git.py
index 6cb089de6..0b66eff9c 100644
--- a/src/lib/Server/Plugins/Git.py
+++ b/src/lib/Server/Plugins/Git.py
@@ -1,5 +1,5 @@
import os
-from subprocess import Popen, PIPE
+from dulwich.repo import Repo
import Bcfg2.Server.Plugin
# for debugging output only
@@ -32,16 +32,9 @@ class Git(Bcfg2.Server.Plugin.Plugin,
def get_revision(self):
'''Read git revision information for the bcfg2 repository'''
try:
- data = Popen(("env LC_ALL=C git ls-remote %s" %
- (self.datastore)), shell=True,
- stdout=PIPE).stdout.readlines()
- revline = [line.split('\t')[0].strip() for line in data if \
- line.split('\t')[1].strip() == 'refs/heads/master'][-1]
- revision = revline
- except IndexError:
- logger.error("Failed to read git ls-remote; disabling git support")
- logger.error('''Ran command "git ls-remote %s"''' % \
- (self.datastore))
- logger.error("Got output: %s" % data)
+ repo = Repo(self.datastore)
+ revision = repo.head()
+ except:
+ logger.error("Failed to read git repository; disabling git support")
raise Bcfg2.Server.Plugin.PluginInitError
return revision