summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-12-02 18:12:52 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-12-02 18:12:52 +0000
commit5a00cd1535e1e3373827e5b53e30f8cfb15fdf35 (patch)
tree6909bc22e24c52ef8ad4a1028eb92f45507a507a /src
parentc07e3b9d4953cc49fdcf68731eef0d007ec8971c (diff)
downloadbcfg2-5a00cd1535e1e3373827e5b53e30f8cfb15fdf35.tar.gz
bcfg2-5a00cd1535e1e3373827e5b53e30f8cfb15fdf35.tar.bz2
bcfg2-5a00cd1535e1e3373827e5b53e30f8cfb15fdf35.zip
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 <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5608 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-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