From 5a00cd1535e1e3373827e5b53e30f8cfb15fdf35 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Wed, 2 Dec 2009 18:12:52 +0000 Subject: Git: Migrate git plugin to Dulwich Using Dulwich gives us a native python implementation of the git file formats and protocols. This gives us more flexibility when we want to extend the plugin to perform other tasks (e.g. automated commits). Signed-off-by: Sol Jerome git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5608 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/Git.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src') 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 -- cgit v1.2.3-1-g7c22